Someone can help me with a UI Policy onCondition to create script to target an specific country?

Leni Lunderman1
ServiceNow Employee
ServiceNow Employee

Hi everyone.

Could someone help me with an onCondition( ) script inside UI Policy? Since I cannot dot walk using the GUI to > Country Code = 'Canada'.

 

I will need to write a script that does the following:

If the country code is 'Canada', make the field "interior" and "exterior" visible and mandatory.

 

These two fields will be available only for users in Canada.

Thank you.

 

1 ACCEPTED SOLUTION

SANDEEP28
Mega Sage

@Leni Lunderman1 You can do dot walk in UI Policy. Follow below steps

1) Select table as "sn_hr_er_case (Employee relations)"

2) In the "When to apply" section, select "Show Related Fields"

 

SANDEEP28_0-1692770526141.png

 

3) Again click on same dropdown and Select "Subject Person --> User fields"

 

SANDEEP28_1-1692770645366.png

 

4) Again click on same drop down and This will allow you to select subject person user record fields.

 

SANDEEP28_2-1692770724519.png

 

Select country code field and its value

 

SANDEEP28_3-1692770807348.png

 

If I could help you with your Query then, please hit the Thumb Icon and mark as Correct !! 

 

 

 

 

View solution in original post

7 REPLIES 7

I would like to be based on the Subject Person since it is an ER case.
If the Subject Person is from Canada, then make the fields "Interior" and "Exterior" mandatory and visible.

Since I cannot dot walk on the UI Policy (It didn't work when I tried)
So, I need to make sure that my onCondition() function, checks if the subject person is from Canada, if so... make the two fields visible in the form and mandatory.

If you are trying to apply this in backend native ui then you need to select "show related fields" in apply condition select box then only you can dot walk. But if it's on portal/catalog then you can not dot walk in portal reference field using ui policy.
I would recommend to use client script with AJAX call to achieve it.

SANDEEP28
Mega Sage

@Leni Lunderman1 You can do dot walk in UI Policy. Follow below steps

1) Select table as "sn_hr_er_case (Employee relations)"

2) In the "When to apply" section, select "Show Related Fields"

 

SANDEEP28_0-1692770526141.png

 

3) Again click on same dropdown and Select "Subject Person --> User fields"

 

SANDEEP28_1-1692770645366.png

 

4) Again click on same drop down and This will allow you to select subject person user record fields.

 

SANDEEP28_2-1692770724519.png

 

Select country code field and its value

 

SANDEEP28_3-1692770807348.png

 

If I could help you with your Query then, please hit the Thumb Icon and mark as Correct !!