Client Script and UI policy on incident in Scope Global doesn't work on SOW

Yanping Guo1
Tera Contributor

I have customized fields on Incident form. I have added those fields on Incident view sow_new_record. Client Script and UI policy works on those field in Incident form, but it doesn't work on the view sow_new_record. 

Incident default view is in scope Global , the view sow_new_record is in scope incidrnt management for service operations workspace.  Is this the reason?

 

Second question:

I create a client script onChange:

      g_form.clearValue('u_data');
      g_form.showFieldMsg('u_data', 'Please enter a valid data in the xxx-xxx-xxxx format', 'error');
when user enter the data in a wrong format. Data will be clear. But the message doesn't stay. It just flashes and then disappear.  How to resolve this issue?
Thanks!

 

Thanks!

1 ACCEPTED SOLUTION

below should work to get the view name in the client script dynamically.
"var view = g_form.getViewName()"

View solution in original post

5 REPLIES 5

Sumanth16
Kilo Patron

Hi @Yanping Guo1 ,

 

UI policies work in workspaces. check if your UI policy applied to your workspace view

 

example

Sumanth16_0-1710904188705.png

 

 

https://support.servicenow.com/kb?id=kb_article_view&sysparm_article=KB0693345

 

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

 

Thanks & Regards,

Sumanth Meda

Haseeb-Ahmed
ServiceNow Employee
ServiceNow Employee

Hi @Yanping Guo1 ,

1. You may verify if you have selected UI type as all, Global = true(if false select correct view), and correct table and field value

Screenshot 2024-03-20 at 6.12.11 PM.png

2. I inspected the field obj and found that the field message is part of field obj, so when you change/clear the field value, it leads to clear message also, so this behavior is expected.

I guess you may leave the field value as it is and show field message to notify user for correction

Screenshot 2024-03-20 at 6.10.23 PM.png

 

Please mark it helpful, if it answers your query.

Thanks,
Haseeb Ahmed

Yanping Guo1
Tera Contributor

Haseeb,

 

Thank you for reply. 

1.  It is perfect answer. Thank you!

2.  If don't clear the value, we need to create an other client script to varify the format / value. Otherwise, the wrong value will be saved.

It works on platform, it has issue in workspace.

 

Thanks

 

Yanping Guo1
Tera Contributor

How do we get view name from client script?

getView() doesn't work.