- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-08-2023 06:54 AM
Hello folks,
i would like to create catalog variable which will be invisible/visible based on the value of different reference variable.
Basically, if variable1 referenced value has more than 1 items assigned to it variable2 is visible, if variable1 referenced value has only one 1 item assigned to it variable2 is invisible.
I have created catalog ui policy but its not working. Variable2 is visible false,onLoad, reverse if false but its not workign. I checked script in background script and works fine.
Thanks for any help or suggestions.
script
function onCondition() {
var variable1= g_form.getUniqueValue('variable1');
var numberCount = 0;
if (portfolio) {
var GR = new GlideRecord('table of the reference variable2');
GR .addQuery('myquery1', myquery);
GR .addQuery('myquery2', myquery);
GR .query();
numberCount = GR .getRowCount();
}
if (numberCount === 1) {
return true;
}
}
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-08-2023 07:53 AM
Considerations:
1. UI Policies are UI based. Hence, GlideRecord would not work in UI Policy scripts. Need to use GlideAjax
2. In UI Policies, its Actions are executed before its scripts. So, you probably need to show/hide the field not using Actions but in the script
3. If you go with #2, then if you are making a field visible in 'Execute if true', then you will need to hide the field in 'Execute if false'
4. I am guessing you have set 'Run scripts in UI type' correctly based on from which interface you are testing (Portal vs Core UI)
I suggest using Client Script instead of UI Policy.
Hope it helps.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-08-2023 07:34 AM
Hello , Can you please share the pictures to get more context.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-08-2023 07:53 AM
Considerations:
1. UI Policies are UI based. Hence, GlideRecord would not work in UI Policy scripts. Need to use GlideAjax
2. In UI Policies, its Actions are executed before its scripts. So, you probably need to show/hide the field not using Actions but in the script
3. If you go with #2, then if you are making a field visible in 'Execute if true', then you will need to hide the field in 'Execute if false'
4. I am guessing you have set 'Run scripts in UI type' correctly based on from which interface you are testing (Portal vs Core UI)
I suggest using Client Script instead of UI Policy.
Hope it helps.