- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
On my catalog item I have a variable called add_company. If that company is filled out, a team will get a task to update the name variable on the core_company table. Once that task is closed, the requirement is to auto update the company variable on the sys_user record.
I think I need a script to do this since the company table is not on the sys_user table.
Any assistance with this would be greatly appreciated.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Try it
Create the Business Rule
- Name: Update User Company from Catalog Task
- Table: Catalog Task [sc_task]
- Advanced: Checked
- When: after
- Update: Checked
- Order: 100
Set the condition to ensure this only runs for your specific task and when it is closed.
State Changes to Closed Complete
AND
Short description Contains <your task description>
(function executeRule(current, previous /*null when async*/) {
var ritmGR = new GlideRecord('sc_req_item');
if (ritmGR.get(current.request_item)) {
var companySysId = ritmGR.variables.add_company;
if (companySysId && userSysId) {
var userGR = new GlideRecord('sys_user');
if (userGR.get(userSysId)) {
userGR.company = companySysId;
userGR.update();
ritmGR.work_notes = "User " + userGR.name + " company updated to " + userGR.company.getDisplayValue();
ritmGR.update();
}
}
}
})(current, previous);
Regards
Tanushree Maiti
ServiceNow Technical Architect
LinkedIn: https://www.linkedin.com/in/tanushreemaiti
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Thank you, I will give your solution a try.