- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-01-2024 05:52 PM
I want to know how to auto-populate the assigned to field with the incident location location support and auto populate the assignment group field with the incident location's assignment group if the user selects ACD or Call Center as the service offering before saving the form. I created a before business rule and it is only populating after the form is saved.
See screenshots below
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-01-2024 06:02 PM - edited 10-01-2024 06:03 PM
Hello @Rhonda9
In ServiceNow, an "onChange" client script is used to execute JavaScript code when a specific field's value changes. This can be useful for dynamically updating other fields, validating input, or displaying messages based on the user's selections.
Since you are trying to auto populate fields on form, onChange Client script could be the possible solution.
"If you found my answer helpful, please give it a like and mark it as the accepted solution. It helps others find the solution more easily and supports the community!"
Thank You
Juhi Poddar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-01-2024 06:02 PM - edited 10-01-2024 06:03 PM
Hello @Rhonda9
In ServiceNow, an "onChange" client script is used to execute JavaScript code when a specific field's value changes. This can be useful for dynamically updating other fields, validating input, or displaying messages based on the user's selections.
Since you are trying to auto populate fields on form, onChange Client script could be the possible solution.
"If you found my answer helpful, please give it a like and mark it as the accepted solution. It helps others find the solution more easily and supports the community!"
Thank You
Juhi Poddar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-01-2024 06:57 PM
You need to
1. Write an onchange client script on 'Service Offering' field.
2. When selected value is call center/acd and if the location field is not empty, then call a script include from this onchange client script and pass the sys_id of the selected location as input.
3. In the script include, create a function to query the location table with the input sys_id.
4. From the queried record, get the value of location assignment group and assigned to information which you need and store it in a object type variable. E.g. var result = {"assignment_group": locationrecord groupSysid, "assigned_to": locationrecord userSysid}
5. Return the result from the script include. In the client script, parse the result to get the assigned to and assignment group values and set the necessary fields in the form.
Since the above change is triggered by an onChange client script, you'll see the changes happening in real time.
Refer to the below link to understand how to call script include from client script.
https://developer.servicenow.com/dev.do#!/reference/api/xanadu/client/c_GlideAjaxAPI
PS: Hit "Correct", "Helpful" or "Like" depending on the impact of the response.
Regards,
Kamal S
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-01-2024 07:06 PM
Thank you , I will definitely give this a try.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-01-2024 07:26 PM - edited 10-01-2024 07:27 PM
This is what I have and it does not seem to work:
Client Script