UI Policy not working properly for values set by catalog client scripts

Kruthik M Shiva
Tera Contributor

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.

4 REPLIES 4

AakashG0904
Tera Expert

Hi @Kruthik M Shiva,

Hope you are doing well.

 

Proposed Solution 

Request you to try steps mentioned below: -

  1. 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".
  2. 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

Alp Utku
Mega Sage

It would be great, If you can provide any scripts / screenshots for the reference.

Vishwa Pandya19
Mega Sage

Hello,

Please provide screenshots so we can help you.

AakashG0904
Tera Expert

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

AakashG0904_0-1712756243861.png

 

2. Catalog Client Script

AakashG0904_1-1712756353846.png

 

3. Catalog UI Policy

AakashG0904_2-1712756389836.png

AakashG0904_4-1712756422698.png

 

3. Output - Showing Confirm Message as Form get Loaded to make the checkbox as Checked.

AakashG0904_5-1712756674615.png

4. Output - If "OK" is chosen by the User

AakashG0904_6-1712756699871.png

5. Output - Choice Field gets Visible to the User if Checkbox is Checked as per the Client Script and UI Policy.

AakashG0904_7-1712756717264.png

6. Output - If "Cancel" is chosen by the User

AakashG0904_8-1712756741877.png

7. Output - Choice Field gets Invisible to the User if Checkbox is Unchecked as per the Client Script and UI Policy.

AakashG0904_9-1712756763217.png

 

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