UI policy on sc_task table

Abhilash Janga1
ServiceNow Employee
ServiceNow Employee

I have created two UI policies on "sc_task" table as follows

1) Name/Short Description = Show Priority for Request Something Else

 Order = 100

When to Run = "Request item.item" is "Request Something Else"

UI policy Action = priority field to make visible

2) Name/Short Description = Show Priority for VMP & SMART

 Order = 100

When to Run = "Request item.item" is "SMART" or "Request item.item" is  "VMP"

UI policy Action = priority field to make visible & read only

 

In this case only the 2nd UI policy is resulting. i.e. Making Priority field visible & read only on 'sc_task' record where 'Request item.item' is 'SMART' or 'VMP'.

But i also want to run 1st UI policy to result Priority field to be visible on 'sc_task' record where 'Request item.item'  is 'Request Something Else'. 

Please if someone can help me with this. Whether it is possible with UI policy or should i go for Client Script?

 

1 ACCEPTED SOLUTION

AMan1997
Tera Guru

Hi,

Please see if the checkbox "Reverse if false" is true on both UI policies. Uncheck it and try again.

Thanks and Regards,

Aman 

 

 

View solution in original post

11 REPLIES 11

shloke04
Kilo Patron

Hi @Abhilash Jangam 

Instead of writing two UI Policy you can write a single On Load client script on Catalog task form and use the script as below:

1) Create a Display Business Rule which will be used to check for your catalog item Name:

BR Details:

Table Name: Catalog task

When: Display

Script:

(function executeRule(current, previous /*null when async*/) {

	// Add your code here
	g_scratchpad.ITEMNAME = current.request_item.cat_item.name.toString();

})(current, previous);

find_real_file.png

Now just write a On Load Client Script on Catalog Task table and use the script as below:

function onLoad() {
    //Type appropriate comment here, and begin script below
    if (g_scratchpad.ITEMNAME == 'Request Something Else') {
        g_form.setDisplay('priority', true);
        g_form.setReadOnly('priority', false);
    } else if (g_scratchpad.ITEMNAME == 'VMP' || g_scratchpad.ITEMNAME == 'SMART') {
        g_form.setDisplay('priority', true);
        g_form.setReadOnly('priority', true);
    } else {
        g_form.setDisplay('priority', false);
    }
}

Also in my script above if the Catalog item is neither of the three which you have mentioned like Smart or VRM or etc then Priority field will not be visible:

find_real_file.png

This should work for you. Let me know if you are facing an issue.

Hope this helps. Please mark the answer as correct/helpful based on impact.

Regards,
Shloke

Hope this helps. Please mark the answer as correct/helpful based on impact.

Regards,
Shloke

shloke04
Kilo Patron

Hi @Abhilash Jangam 

Just checking which method you went with UI Policy or client script (which was suggested by me). If you went with client script then can you please mark the appropriate answer as correct.

I don't have any concerns with other answer being marked as correct  but wanted to check and confirm with you for the appropriate response.

Regards,

Shloke

Hope this helps. Please mark the answer as correct/helpful based on impact.

Regards,
Shloke