How do I set field values through scripting for mobile action items?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-22-2020 09:34 PM
I noticed that screen ui policies do not work if I don't set the fields in the"Set field values" field in the action item settings.
I need to do "type" script instead of "update" because I am doing more complicated things with this action item. Is there a way to set these fields through scripting so that the screen ui policies work?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-23-2020 09:18 AM
Hi Brianlion,
If you want to select type script, you can write a usual Snow script to update/insert/delete a record, but that may or may not work with UI policies, you must give it a try by creating a new GlideRecord('table_name') and provide current sysid as condition and then do set field values as usual Snow script, it should work based on the Mobile UI policies documentation.
Thanks
Aniket
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-23-2020 12:23 PM
Hi Aniket,
Can you please provide an example of setting the fields through scripting?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-23-2020 08:43 PM
Hi Brian,
Here's an example for Create Incident. But you can use similar code for update, the only difference would be that you first do a gr.get(inputs.sys_id) on incident table and then set the fields before ending it with gr.update();
Please mark the answer as helpful/correct based on the impact.
Thanks
Aniket
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-27-2020 03:40 PM
Scripted conditions on UI policies are not supported for mobile as of NY/Orlando.
The best way to gain additional support for this enhancement is to add/upvote it to our idea portal on community so it can gain traction and we can further conversation on this:
https://community.servicenow.com/community?id=ideas_list&sysparm_module_id=enhancement_requests
Best,
David