Updating the value of certain field in a number of records from User table using Background Script
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-26-2023 02:42 AM
Hi, Need help in writing the background script!
Below is the requirement:
I have a custom table which has a Country field in it and it is populated based on user selected in the field Engagement Partner and my requirement is to update the Country field value in this custom table for a number of records by searching the the user from "User" table and picking up the value of Country from User table and updating the value into Country field in custom table.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-26-2023 03:20 AM
please share what script did you start with and where are you stuck?
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-26-2023 03:25 AM
I am not able to understand how to start with it!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-26-2023 03:41 AM
unless you start how will you learn
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-26-2023 04:59 AM
Here are the steps to design the script to fulfill your requirement
- "GlideRecord" the custom table you created
- Add the "encodedQuery" as per your requirement the "Query' it
- Within the while loop, query the sys_user table with the encodedQuery of sys_id=u_engagement_partner, and then query it
- Get the value of the country field set that value in your custom table field and then update it.
Would you mind designing a script and come back to here, will help you then.
Best Regards,
Tarun