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.
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.
Well, I guess you can do an onlyread field, as same as you do with the relationship of the role field you can do with readonly.
If I am sure you must do
$dictionary['<module>']['fields']['<field_name>']['filter_definition']['readonly'] = true;
And that converts the field in a simply label, not editable by the user.