Reference qual on a variable reference field
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-08-2024 04:13 AM
Hey,
On a form i have a variable which is a reference field from a system table.
on the advanced Reference qual i have the script:
javascript: if(current.variables.rule_type == 'Custom') 'u_status!=Retired^u_system_idSTARTSWITHS'; else 'u_system_idSTARTSWITHS^u_status!=Retired^u_auth_requestorLIKEjavascript:gs.getUserID()^ORu_systme_access_manager_sam=javascript:gs.getUserID()^ORu_system_manager=javascript:gs.getUserID()^ORu_system_owner=javascript:gs.getUserID()';
But i would also like to add in the else, if the person has the role of "Order Manager". So i tried to add this into the qualifier like this:
javascript: if(current.variables.rule_type == 'Custom') 'u_status!=Retired^u_system_idSTARTSWITHS'; else 'u_system_idSTARTSWITHS^u_status!=Retired^u_auth_requestorLIKEjavascript:gs.getUserID()^ORu_systme_access_manager_sam=javascript:gs.getUserID()^ORu_system_manager=javascript:gs.getUserID()^ORu_system_owner=javascript:gs.getUserID()^ORgs.hasRole('Order Manager)';
But its not working like intended, so nothing is showing up for the person with the role of "Order Manager".
Does anybody know what the issue might be here in the qualifier?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-08-2024 06:16 AM
Hi @AbooK
Since your reference qualifier is too complex with JavaScript code due to requirement, so I would suggest you to please use script include function and call script include function in your reference qualifier.
In you script include function, you just add your condition then return encoded query as string as per condition which you want. and use same in reference qual as below:
javascript:new scriptincludename().functionname(current.variables.var_name);
variablevalue - option, if you want to use it in script.
you can also add more parameter, if you want to use more than one variable values in your script.
As from first look in your ref qual, you are not using any {} with your if condition, although if you are using some condition then you need to define function and then return value from function as encoded query if still you want to use reference qual only without script include.
If my answer helped you in any way please mark it as helpful or correct.
Thank You.
Regards,
Shubham Gupta
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-08-2024 06:32 AM
Hey @Shubham26 thanks for the answer.
I was hoping to not use a script include, as I am not really much of a coder, thats why I just wanted to add a line into the existing code if that was to be possible?.
Is it possible to achieve this without using a script include?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-08-2024 11:56 PM
Hi @AbooK
Can you please try with below code:
javascript: getRefQual(current.variables.rule_type); function getRefQual(val) {
if (val == 'Custom') {
return 'u_status!=Retired^u_system_idSTARTSWITHS';
} else {
var additionalQualifier = gs.hasRole('Order Manager') ? '^ORu_role=order_manager' : '';
return 'u_system_idSTARTSWITHS^u_status!=Retired^u_auth_requestorLIKEjavascript:gs.getUserID()^ORu_systme_access_manager_sam=javascript:gs.getUserID()^ORu_system_manager=javascript:gs.getUserID()^ORu_system_owner=javascript:gs.getUserID()' + additionalQualifier;
}}
Kindly confirm if it works or not.
If my answer helped you in any way please mark it as helpful or correct.
Thank You.
Regards,
Shubham Gupta
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-08-2024 07:30 AM
@AbooK Try with below
javascript:
if (current.variables.rule_type == 'Custom') {
'u_status!=Retired^u_system_idSTARTSWITHS';
} else {
var additionalQualifier = gs.hasRole('Order Manager') ? '^ORu_role=order_manager' : '';
'u_system_idSTARTSWITHS^u_status!=Retired^u_auth_requestorLIKEjavascript:gs.getUserID()^ORu_systme_access_manager_sam=javascript:gs.getUserID()^ORu_system_manager=javascript:gs.getUserID()^ORu_system_owner=javascript:gs.getUserID()' + additionalQualifier;
}
Please Mark ✅Correct if this solves your query and also mark 👍Helpful if you find my response worthy based on the impact.
Thanks