Can anyone tell me how I can have an office phone automatically fill in a Contact when we select an Account name?
It should do that automatically. Look in /modules/Contacts/metadata/editviewdefs.php, and you should see the following.
array (
'name' => 'account_name',
'displayParams' =>
array (
'key' => 'billing',
'copy' => 'primary',
'billingKey' => 'primary',
'additionalFields' =>
array (
'phone_office' => 'phone_work',
),
),
i use version 5.3.3. I want to do the same thing with a small difference. when i am in an account and i want to create a quote, some information like billing address… transfer automatically but my custom field not…
I add in /modules/Accounts/metadata/editviewdefs.php this part of code:
2 =>
array (
0 =>
array (
‘name’ => ‘afm2_c’,
‘label’ => ‘LBL_AFM2’,
‘displayParams’ =>
array(
‘afm_timologisis_c’=> array(
‘name’ => ‘afm2_c’,
),
),
),
I want the value afm_timilogisis_c (quotes) to have the same value with afm2_c (accounts). That happens when i create a quote in an account with the address fields.
It doesn’t work with my custom fiels? Is anything false? Must i add this code in another folder-file? Must i change anything?
Thanks
Related
I am integrating PayPal Checkout which works nicely unless I include a custom payee in the order body. I tried the PayPal PHP example at https://developer.paypal.com/docs/checkout/integration-features/custom-payee/ that looks like this:
return array(
'intent' => 'AUTHORIZE',
'purchase_units' =>
array(
0 =>
array(
'amount' =>
array(
'currency_code' => 'USD',
'value' => '220.00'
)
),
array(
'payee' =>
array(
'email_address' => 'payee#email.com'
)
)
)
);
Trying to create an order will lead to this error message (which seems to be completely wrong as it complaints about fields that are neither there nor needed):
{"name":"INVALID_REQUEST","message":"Request is not well-formed, syntactically incorrect, or violates schema.","debug_id":"65a47f1e8defd","details":[{"field":"/purchase_units/1/amount","value":"","location":"body","issue":"MISSING_REQUIRED_PARAMETER","description":"A required field / parameter is missing."}],"links":[{"href":"https://developer.paypal.com/docs/api/orders/v2/#error-MISSING_REQUIRED_PARAMETER","rel":"information_link","encType":"application/json"}]} [/var/www/web15/htdocs/retroplace/vendor/paypal/paypalhttp/lib/PayPalHttp/HttpClient.php:215]
If I remove the portion with the payee, everything works fine. But I need the payee in the order...
Do you have PHP errors/warnings enabled? that looks like it might be bad PHP syntax
Try putting:
'payee' =>
array(
'email_address' => 'payee#email.com'
)
Within the array above (second key, in the same array as 'amount')
I am having a problem in updating values i get from web service ..
$collection = $modb->$table;
$collection->update(array("id" => (int)$row['id']),
array('$set' => array(
"user_id" => (int)$post_data_array['user_id'],
"story" => (int)$post_data_array['story'],
"surprize_sub1" => (int)$post_data_array['surprize_sub1'],
"surprize_sub2" => (int)$post_data_array['surprize_sub2'],
"surprize_sub3" => (int)$post_data_array['surprize_sub3'],
"exr_solve" => (int)$post_data_array['exr_solve'],
"exr_assessmnt" => (int)$post_data_array['exr_assessmnt'],
"exr_refresh" => (int)$post_data_array['exr_refresh'],
"sound_control" => (int)$post_data_array['sound_control'],
"clock_control" => (int)$post_data_array['clock_control'],
"switch_user" => (int)$post_data_array['switch_user'],
"exr_print" => (int)$post_data_array['exr_print'],
"write_on_wall" => (int)$post_data_array['write_on_wall'],
"switch_letter" => (int)$post_data_array['switch_letter'],
"view_controls" => (int)$post_data_array['view_controls'],
)));
I get these values from end users.. i want the specific field sent to be updated without loosing all the rest of data ..
in this code only sent data is set while removing the rest .. i want to change only sent ones by keeping the rest as they are, please advice
you need to use updateOne instead of update .
updateOne
Use the MongoDB\Collection::updateOne() method to update a single document matching a filter.
$collection = $modb->$table;
$collection->updateOne(array("id" => (int)$row['id']),
array('$set' => array(
// .... array elements
)));
I want to filter list that does not have an invalid email and opt-out email in Leads and Contact module using SugarCRM 7 API.
I have added below email filter in arguments but does not work. How to email filter via SugarCRM 7.x rest API.
$filter_arguments = array(
"filter" => array(
array(
"assigned_user_id" => 1,
),
array(
"email1" => array(
array(
'opt_out' => array(
'$equals' => ''
)
)
)
),
),
);
$url = $base_url . "/Contacts/filter";
Thanks.
This much code will not help you please check this :
Reference Link 1
Reference Link 2
The following example will demonstrate how to add a predefined filter on the Accounts module to return all records with an account type of "Customer" and industry of "Other".
To create a predefined filter, create a display label extension in ./custom/Extension/modules/<module>/Ext/Language/. For this example, we will create:
./custom/Extension/modules/Accounts/Ext/Language/en_us.filterAccountByTypeAndIndustry.php
<?php
$mod_strings['LBL_FILTER_ACCOUNT_BY_TYPE_AND_INDUSTRY'] = 'Customer/Other Accounts';
Next, create a custom filter extension in ./custom/Extension/modules/<module>/Ext/clients/base/filters/basic/.
For this example, we will create:
./custom/Extension/modules/Accounts/Ext/clients/base/filters/basic/filterAccountByTypeAndIndustry.php
<?php
$viewdefs['Accounts']['base']['filter']['basic']['filters'][] = array(
'id' => 'filterAccountByTypeAndIndustry',
'name' => 'LBL_FILTER_ACCOUNT_BY_TYPE_AND_INDUSTRY',
'filter_definition' => array(
array(
'account_type' => array(
'$in' => array(
'Customer',
),
),
),
array(
'industry' => array(
'$in' => array(
'Other',
),
),
),
),
'editable' => false,
'is_template' => false,
);
You should notice that the editable and is_template options have been set to "false". If editable is not set to "false", the filter will not be displayed in the list view filter's list.
Finally, navigate to Admin > Repair and click "Quick Repair and Rebuild" to rebuild the extensions and make the predefined filter available for users.
Adding Initial Filters to Lookup Searches
To add initial filters to record lookups and type-ahead searches, define a filter template. This will allow you to filter results for users when looking up a parent related record. The following example will demonstrate how to add an initial filter for the Account lookup on the Contacts module. This initial filter will limit records to having an account type of "Customer" and a dynamically assigned user value determined by the contact's assigned user.
To add an initial filter to the Contacts record view, create a display label for the filter in ./custom/Extension/modules/<module>/Ext/Language/. For this example , we will create:
./custom/Extension/modules/Accounts/Ext/Language/en_us.filterAccountTemplate.php
<?php
$mod_strings['LBL_FILTER_ACCOUNT_TEMPLATE'] = 'Customer Accounts By A Dynamic User';
Next, create a custom template filter extension in ./custom/Extension/modules/<module>/Ext/clients/base/filters/basic/.
For this example, create:
./custom/Extension/modules/Accounts/Ext/clients/base/filters/basic/filterAccountTemplate.php
<?php
$viewdefs['Accounts']['base']['filter']['basic']['filters'][] = array(
'id' => 'filterAccountTemplate',
'name' => 'LBL_FILTER_ACCOUNT_TEMPLATE',
'filter_definition' => array(
array(
'account_type' => array(
'$in' => array(),
),
),
array(
'assigned_user_id' => ''
)
),
'editable' => true,
'is_template' => true,
);
As you can see, the filter_definition contains arrays for account_type and assigned_user_id. These filter definitions will receive their values from the contact record view's metadata. You should also note that this filter has is_template and editable set to "true". This is required for initial filters.
Once the filter template is in place, modify the contact record view's metadata. To accomplish this, edit ./custom/modules/Contacts/clients/base/views/record/record.php to adjust the account_name field. If this file does not exist in your local Sugar installation, navigate to Admin > Studio > Contacts > Layouts > Record View and click "Save & Deploy" to generate it. In this file, identify the panel_body array as shown below:
1 =>
array (
'name' => 'panel_body',
'label' => 'LBL_RECORD_BODY',
'columns' => 2,
'labelsOnTop' => true,
'placeholders' => true,
'newTab' => false,
'panelDefault' => 'expanded',
'fields' =>
array (
0 => 'title',
1 => 'phone_mobile',
2 => 'department',
3 => 'do_not_call',
4 => 'account_name',
5 => 'email',
),
),
Next, modify the account_name field to contain the initial filter parameters.
1 =>
array (
'name' => 'panel_body',
'label' => 'LBL_RECORD_BODY',
'columns' => 2,
'labelsOnTop' => true,
'placeholders' => true,
'newTab' => false,
'panelDefault' => 'expanded',
'fields' =>
array (
0 => 'title',
1 => 'phone_mobile',
2 => 'department',
3 => 'do_not_call',
4 => array (
//field name
'name' => 'account_name',
//the name of the filter template
'initial_filter' => 'filterAccountTemplate',
//the display label for users
'initial_filter_label' => 'LBL_FILTER_ACCOUNT_TEMPLATE',
//the hardcoded filters to pass to the templates filter definition
'filter_populate' => array(
'account_type' => array('Customer')
),
//the dynamic filters to pass to the templates filter definition
//please note the index of the array will be for the field the data is being pulled from
'filter_relate' => array(
//'field_to_pull_data_from' => 'field_to_populate_data_to'
'assigned_user_id' => 'assigned_user_id',
)
),
5 => 'email',
),
),
Finally, navigate to Admin > Repair and click "Quick Repair and Rebuild". This will rebuild the extensions and make the initial filter available for users when selecting a parent account for a contact.
Adding Initial Filters to Drawers from a Controller
When creating your own views, you may need to filter a drawer called from within your custom controller. Using an initial filter, as described in the Adding Initial Filters to Lookup Searches section, we can filter a drawer with predefined values by creating a filter object and populating the config.filter_populate property as shown below:
//create filter
var filterOptions = new app.utils.FilterOptions()
.config({
'initial_filter': 'filterAccountTemplate',
'initial_filter_label': 'LBL_FILTER_ACCOUNT_TEMPLATE',
'filter_populate': {
'account_type': ['Customer'],
'assigned_user_id': 'seed_sally_id'
}
})
.format();
//open drawer
app.drawer.open({
layout: 'selection-list',
context: {
module: 'Accounts',
filterOptions: filterOptions,
parent: this.context
}
});
To create a filtered drawer with dynamic values, create a filter object and populate the config.filter_relate property using the populateRelate method as shown below:
//record to filter related fields by
var contact = app.data.createBean('Contacts', {
'first_name': 'John',
'last_name': 'Smith',
'assigned_user_id': 'seed_sally_id'
});
//create filter
var filterOptions = new app.utils.FilterOptions()
.config({
'initial_filter': 'filterAccountTemplate',
'initial_filter_label': 'LBL_FILTER_ACCOUNT_TEMPLATE',
'filter_populate': {
'account_type': ['Customer'],
},
'filter_relate': {
'assigned_user_id': 'assigned_user_id'
}
})
.populateRelate(contact)
.format();
//open drawer
app.drawer.open({
layout: 'selection-list',
context: {
module: 'Accounts',
filterOptions: filterOptions,
parent: this.context
}
});
I am trying to implement the 'InArray' validator in Zend 2 on a form and it keeps on returning invalid. Here is the code:
The Form Element setup:
$enquiryType = new Element\Select('enquiryType');
$enquiryType->setLabel('* What is your enquiry about?')
->setLabelAttributes(array('class' => 'sq-form-question-title'))
->setAttribute('class', 'sq-form-field required')
->setValueOptions($enquiryTypes);
The Filter/Validator setup:
$enquiryType = new Input('enquiryType');
$enquiryType->getValidatorChain()
->addByName('InArray', array('haystack' => $enquiryTypes));
And here is the array that gets passed into $enquiryTypes via the module.config.php file
'enquiryCategories' => array(
'empty_option' => 'Please select an option',
array(
'label' => 'General enquiries',
'options' => array(
'skype' => 'Skype with your library feedback',
'question' => 'Ask a question',
'feedback' => 'Library feedback',
'eresource' => 'Electronic resources (e.g. e-book, e-journal, database)',
'webbridge' => 'WebBridge Problems',
'dro' => 'DRO'
)
),
array(
'label' => 'Application to review',
'options' => array(
'10400' => 'I\'ve returned the item',
'10401' => 'I didn\'t know about overdue points but now I have some',
'10402' => 'Why did I get this invoice?',
'10403' => 'The item I borrowed is lost',
'10404' => 'The item I borrowed has been damaged',
'10405' => 'I never got/had the book',
'10406' => 'Other'
)
)
),
I have tried different variations of this (using the recursive validation also) but have not been able to work this out.
One thing that I'd try, is as follows:
$enquiryType = new Input('enquiryType');
$enquiryType->getValidatorChain()
->addByName('InArray', array('haystack' => $enquiryTypes['enquiryCategories']));
The reason I say that, is that it looks like you might be creating an array inside of the array perhaps. Unless I've misunderstood the description.
If that isn't working for you then maybe you might need to explore the Explode option as pointed out in the following question
ZF2: How do I use InArray validator to validate Multiselect form element?
Good luck.
I finally got a working solution for this. I feel there should be a better solution but I could not find one.
Here is the filter I used:
$enquiryType = new Input('enquiryType');
$enquiryType->getValidatorChain()
->addByName('InArray', array('haystack' => array_keys(
$enquiryTypes[0]['options']+$enquiryTypes[1]['options']
)));
$enquiryType->getFilterChain()
->attach(new Filter\StringToLower())
->attachByName('StripTags');
Basically I had to disect the array options into a straight associative array. As the array remains static in this instance then this works well.
If the data becomes dynamic then something more would be required (loop through and find the 'option' key, add children to filter array etc...)
I've looked at loads of forums about validation errors not showing and tried various things but to no avail...
Basically, the validation is correctly recognising the fields do not have values when they should, however the error messages don't 'automagically' appear below the input boxes.
Model validation rule is shown below:
var $validate = array(
'description' => array(
'rule' => 'notEmpty',
'required' => true,
'allowEmpty' => false,
'message' => 'Please enter a description of the change'
)
);
echo pr($this->data); output is shown below:
Array
(
[Change] => Array
(
[0] => Array
(
[id] => 3237
[cn_id] => 5132
[req_id] => 25
[description] =>
)
[1] => Array
(
[id] => 3238
[cn_id] => 5132
[req_id] => 22
[description] =>
)
[2] => Array
(
[id] => 3239
[cn_id] => 5132
[req_id] => 4
[description] =>
)
)
)
echo pr($this->Change->invalidFields()); output is shown below:
Array
(
[0] => Array
(
[description] => Please enter a description of the change
)
[1] => Array
(
[description] => Please enter a description of the change
)
[2] => Array
(
[description] => Please enter a description of the change
)
[description] => Please enter a description of the change
)
So, it is generating the errors messages for display, but they don't actually display in the view, and I don't know why?
Excerpt from the 'view' code is show below:
<?php echo $form->input('Change.'.$i.'.description',
array('value' => $cn['Change'][$i]['description'],
'label' => $engReq['Req']['description'])); ?>
Does anybody have ideas why the error messages are not showing?
I experienced the same issue with a hasMany model (where the form had numerically indexed fields) and came up with a validation solution that worked for me.
Quick answer: Before trying to actually save the data, I validated the data separately like (notice 'validate'=>'only'):
if($this->ModelName->saveAll($this->data, array('validate' => 'only'))) {
// proceed to save...
}
Doing it this way gave me the model's validation error message in the form, right under the input field that failed the validation (the normal Cake way of showing the validation error).
Note: I could not use saveAll() to actually save my data (I'll explain why in a minute). If I could use saveAll() to actually save the data, I could have gotten the validation at the same time as I saved by using (notice 'validate' => 'first'):
if($this->ModelName->saveAll($this->data, array('validate' => 'first')))
However, I could not use saveAll() to actually save the data, due to the fact that I needed to use a transaction to save several models at once, where some of the models were not directly related to other models. saveAll() will only save the model on which it is called, plus models directly related to it. Since Cake does not currently support nested transactions, and saveAll() uses one transaction automatically, I had to use save() on my models and start and end my transaction manually. However, this caused me to loose the validation message in my form on the hasMany items, even if I saved by using "$this->ModelName->save($this->data, array('validate'=>'first')".
Further explanation: The issue does seem to be related to using numerically indexed fields in the form. For example:
$this->Form->input("ModelName.0.field_name");
It seems this indexing scheme is the proper way to handle hasMany items in the form, but the validation messages would not find their way to this form input. It is interesting to notice that my view did in fact have access to the validation error. This can be seen in the view by using (notice no numerical index in these lines):
if($this->Form->isFieldError("ModelName.field_name")) {
echo $this->Form->error("ModelName.field_name");
}
Putting these lines after the '$this->Form->input("ModelName.0.field_name")' inserted a the validation message into the page, just not in the same div as the input field (and thus it didn't look ideal).
I couldn't figure out a way to tell Cake to use that validation message in the '$this->Form->input("ModelName.0.field_name")'. So I resorted to the 'validate' => 'only' method described earlier, which is working well for me.
shouldnt it be
var $validate = array(
'description' => array(
'notEmpty' => array(
'rule' => 'notEmpty',
'required' => true,
'allowEmpty' => false,
'message' => 'Please enter a description of the change'
)
)
);
?