How do I set field values through scripting for mobile action items?

Brianlion
Giga Contributor

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. 

find_real_file.png

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?

 

4 REPLIES 4

Aniket15
ServiceNow Employee
ServiceNow Employee

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

Hi Aniket,

 

Can you please provide an example of setting the fields through scripting?

 

Aniket15
ServiceNow Employee
ServiceNow Employee

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(); find_real_file.png

 

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

Thanks

Aniket 

David Ha
ServiceNow Employee
ServiceNow Employee

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