Update managers of contractors in bulk
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-16-2024 07:13 AM
Hello All,
I have created a service catalog form where the current manager will be the requester and a new manager is selected in the form. Once approved, all the contractors' record under the old manager will be updated with the new manager via automation set in the workflow.
The three fields which needs to be updated in the contractor's profile are -
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-16-2024 07:26 AM - edited 09-16-2024 07:28 AM
@Bidhan_Singha you are missing usris.query(). below is updated script.
(function executeRule(current, previous /*null when async*/ ) {
var usris = new GlideRecord('u_contractors_onboarding');
usris.addQuery('u_manager_ref', current.variables.current_manager);
usris.query();
while (usris.next()) {
usris.u_manager_ref = current.variables.select_a_new_manager; // Manager_MANAGER CAN UPDATE
usris.u_manager = current.variables.select_a_new_manager.getDisplayValue();
usris.u_manager_user_id = current.variables.select_a_new_manager.user_name; //Backend Manager
usris.update();
}
})(current, previous);
Please mark my answer correct and helpful if this works for you.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-16-2024 07:51 AM
Hi Gangadhar,
My bad!! I tried again after adding usris.query(). It is still not working.
As I am not able to find other issue in the script. Can it be possible it is because of the OnChange client script I am using to populate current_manager field in the form.
Here is the client script:
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-16-2024 07:26 AM
You don't have ursis.query() after the ursis.addQuery() line.