Auto populate Assigned to field on a new incident
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-24-2020 10:06 AM
Hello,
I am trying to auto populate the assigned to field on an incident form with a particular user. I am able to do this using a client script using onSubmit type:
g_form.setValue('assigned_to', 'Sys ID of User');
The only problem I have here is that if the assigned to field needs to be changed/updated, It will not save. This user will be permanently assigned to the incident. How can I set it up in a way that allows the assigned to field to be defaulted to that particular user, but if the assigned to needs to be updated with someone else, the system will allow it?
EX:
when I use the provided client script, Tom Jones fills the assigned to field, but when I come back in to modify the field with Jessica Alba and then click save, the field repopulates with Tom Jones and not Jessica Alba.
Thanks!
- 2,198 Views

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-24-2020 10:47 AM
Indeed something like this could also work. Be aware that you are setting a reference field. So actually you should pass the sys_id + displayValue. Without displayValue, an additional server lookup is performed (= performance).
Looking at performance, dictionary override would be nicer to use. So have a look if you can manage that.
If my answer helped you in any way, please then mark it as helpful.
Kind regards,
Mark
2020 ServiceNow Community MVP
2020 ServiceNow Developer MVP
---
Kind regards,
Mark Roethof
Independent ServiceNow Consultant
10x ServiceNow MVP
---
~444 Articles, Blogs, Videos, Podcasts, Share projects - Experiences from the field
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-24-2020 11:40 AM
Can you give show me an example of how I would pass the sys_id and display value?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-24-2020 10:39 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-24-2020 10:42 AM
Thank you for your response
The solution you provided is what I already had. My issue is if the user needs to be changed, this script will not allow it, and will therefore default back to the hardcoded user. I needed to set an if condition using the g_form.getValue()

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-24-2020 10:42 AM
Hi,
Check in your client script, if you are setting the assigned_to always. You need to make it only when assigned_to is empty.
Mark the comment as a correct answer and helpful if it helps.