- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-27-2018 12:52 AM
we have a requirement to apply ui policy action when the respective ui policy should work only on new form not on existing form.
Solved! Go to Solution.
- Labels:
-
Incident Management

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-27-2018 04:56 AM
Yes we can in condition
Place the condition as created by is empty then it will work on new records.
If it is new record then the createdby field is empty so the UI Policy will work on new form. when the record is inserted then the ui policy will not work.
I tested it in my instance and working fine, Pls let me know if you have any queries.
Mark correct or helpful based on the impact.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-27-2018 12:56 AM
Hi Vishnu,
In UI policy there is no such method to know whether it is new record or existing record. better move the code to client script and use g_form.isNewRecord()
Mark Correct if this solves your issue and also hit Like and Helpful if you find my response worthy based on the impact.
Thanks
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-27-2018 04:56 AM
Yes we can in condition
Place the condition as created by is empty then it will work on new records.
If it is new record then the createdby field is empty so the UI Policy will work on new form. when the record is inserted then the ui policy will not work.
I tested it in my instance and working fine, Pls let me know if you have any queries.
Mark correct or helpful based on the impact.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-27-2018 05:07 AM
Hi Sai,
That is a workaround. For below scenario it will fail if someone updates the record in the table and uses autoSysField(false) while clearing the created by field in this case it is an existing record but since created by is empty UI policy will fail and treat it as new record. So recommended approach would be to use client script on safer side.
var gr = new GlideRecord('incident');
gr.addQuery('sys_id','<sysId>');
gr.autoSysFields(false);
gr.query();
if(gr.next()){
gr.sys_created_by = '';
gr.update();
}
Mark Correct if this solves your issue and also mark Helpful if you find my response worthy based on the impact.
Thanks
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-30-2018 05:41 AM
Hi Vishnu,
Any update on this?
Can you mark my answer as correct, helpful if you were able to achieve the requirement. This helps in removing this question from unanswered list and helps users to learn from your thread. Thanks in advance.
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader