UI Policy not working properly for values set by catalog client scripts
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-10-2024 12:38 AM
In the record producer I have few fields in that two fields I have one is checkbox, and another is choice field so once the user clicks on checkbox the choice field should be visible that is working properly if I clicked on checkbox but there is an another scenario the checkbox field we are setting from catalog client script the checkbox value we are setting that time the checkbox value is setting true but the choice field is not getting visible as per the UI policy . what could be the possible issue and how to resolve it.
Thanks in advance.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-10-2024 02:00 AM - edited ‎04-12-2024 06:29 AM
Hi @Kruthik M Shiva,
Hope you are doing well.
Proposed Solution
Request you to try steps mentioned below: -
- Use your "Script" for displaying the "Choice" Field in the "Catalog Client Script" only that you are using to set the value of "Checkbox" Field as "True".
- Try to perform above activity by making the "Catalog UI Policy" as "Active" or "Inactive" both.
If you will still face same issue, request you to provide some snapshots that will be helpful for me to solve your query as soon as possible.
If you find this information/knowledge/solution as helpful, please do not forget to mark the same as Helpful and Accepted as a Solution.
Thanks
Aakash Garg
ServiceNow Developer

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-10-2024 02:01 AM
It would be great, If you can provide any scripts / screenshots for the reference.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-10-2024 03:19 AM
Hello,
Please provide screenshots so we can help you.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-10-2024 06:56 AM - edited ‎04-12-2024 06:29 AM
Hi @Kruthik M Shiva,
Hope you are doing well.
Proposed Solution
As per my trailing solution, I tried to implement your ask or query on my "Personal Developer Instance" so that you can get an effective solution as soon as possible. For this, I created a "Record Producer" named as "Incident Creation", "2 - Catalog Variables" as per of your type "[Checkbox and Choice]", "1 - UI Policy" which is making the "Choice" Field as "Visible and Invisible", and "1 - Catalog Client Script" which I used to set the value of the "Checkbox" Field as "True" via "confirm()" method of JavaScript [Here you will use your own script to set the checkbox as checked]. For your reference, attaching some snapshots of the output and request you to follow the Script mentioned below: -
Catalog Client Script: -
function onLoad() {
g_form.setDisplay('u_assignment_group', false);
var val = confirm('Want to Set Assignement Group?');
alert('You choosed ' + val);
if (val == true) {
g_form.setValue('want_to_add_assignment_group', 'true');
}
}
Snapshots: -
1. Record Producer and Catalog Variables
2. Catalog Client Script
3. Catalog UI Policy
3. Output - Showing Confirm Message as Form get Loaded to make the checkbox as Checked.
4. Output - If "OK" is chosen by the User
5. Output - Choice Field gets Visible to the User if Checkbox is Checked as per the Client Script and UI Policy.
6. Output - If "Cancel" is chosen by the User
7. Output - Choice Field gets Invisible to the User if Checkbox is Unchecked as per the Client Script and UI Policy.
If you find this information/knowledge/solution as helpful, please do not forget to mark the same as Helpful and Accepted as a Solution.
Thanks
Aakash Garg
ServiceNow Developer