How can i add filter on related field . like I have user type related field on which I have want to show only user related user with some role . how is this possible ?
i tried through this
bt not working
How can i add filter on related field . like I have user type related field on which I have want to show only user related user with some role . how is this possible ?
i tried through this
bt not working
You can extend the vardef file to add a "filter_definition". For example, in the field custom/Extension/modules/<module>/Ext/Vardefs/sugarfield_<field_name>.php, you can add something like:
$dictionary['<module>']['fields']['<field_name>']['filter_definition'] = [
[
'aclroles.name' => '<role_name>'
]
];
Then do a quick repair and rebuild - and by default, it will auto-filter based on the definition above - but this doesn't enforce the filter, users are free to remove the filter and set any record they want, but the default search will filter by the role you specify.
Hey Neeranja P,
Could this also work for restricting contacts for accounts in related modules?
Overview:
When an Account is selected and the user goes to choose the Contact, I want to restrict the Contacts available to only those on the Account....but the the detail here is that account is a dynamic values (not like the '<role name'>)..
Link to Simirar case
Example: ( Getting only the contacts of the account selected <TestAccount>)
I've tried like you mention above but im not sure what to consider as my <module>(cases or account) and sugarfield (in custom/Extension/modules/<module>/Ext/Vardefs/sugarfield_<field_name>.php)...is not throwing any errors nor the queries expected.
Hi Karen Escritorio,
Yes this will work for any relate field and dynamic fields as well. It works just like regular filters.
The field where your module is present is the <module>. Lets say this is "Cases" module.
The actual field name that you want to restrict should be <field_name>.. Lets say this is the "contact" field.
So the file that you'll have to create is:
custom/Extension/modules/Cases/Ext/Vardefs/sugarfield_contact.php
Now, all dynamic parameters can be substituted with "#", so in this case, the filter definition could look like:
$dictionary['Case']['fields']['contact']['filter_definition'] = [
[
'account_id' => '#account_id'
]
];
What we're trying to do is to filter Contacts by account_id - and the dynamic parameter to use is the #account_id of the Case module.
Hi Karen Escritorio,
Yes this will work for any relate field and dynamic fields as well. It works just like regular filters.
The field where your module is present is the <module>. Lets say this is "Cases" module.
The actual field name that you want to restrict should be <field_name>.. Lets say this is the "contact" field.
So the file that you'll have to create is:
custom/Extension/modules/Cases/Ext/Vardefs/sugarfield_contact.php
Now, all dynamic parameters can be substituted with "#", so in this case, the filter definition could look like:
$dictionary['Case']['fields']['contact']['filter_definition'] = [
[
'account_id' => '#account_id'
]
];
What we're trying to do is to filter Contacts by account_id - and the dynamic parameter to use is the #account_id of the Case module.