- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-11-2024 06:37 AM
Hello Community,
I'm creating 'New Hire' Order Guide using 'Order Guide Sequential Fulfilment'. I have the below catalog items to be in a sequential order (New Hire account created first and the remaining three items will be created in parallel).
New Hire Account
Hardware Provisioning
Available Software/Application Request
Mobile Device Request
I want to get the new hire user sys_id from the first catalog item (New Hire Account) and use the value in the remaining catalog items 'Requested For' variable.
Can anyone please assist me with this.
Please let me know if you need more information.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-01-2024 04:25 AM
To everyone who is looking for similar question, I have found the solution to it.
As part of the New Hire Account catalog item, a catalog task will be created which will be worked upon by an IT executive. Create a mandatory variable say, Username (mandatory on closure of the catalog task), hence the IT executive will have to add the Username of the newly created user before closing the task.
Get the value of the variable and do a GlideRecord on the User table to get the sys_id of the newly created user record.
Write a Business Rule in the catalog task on closure of the catalog task table to implement the functionality.
var uName = current.variables.username;
var grUser = new GlideRecord('sys_user');
grUser.addQuery('user_id', uName);
grUser.query();
if(grUser.next()) {
var user = grUser.getUniqueValue();
}
Now the user variable will contain the sys_id of the newly created user. Put this sys_id in the requested_for of the other RITMs of that particular Request.
var req = current.request_item.request;
var grRITM = new GlideRecord('sc_req_item');
grRITM.addQuery('request', req);
grRITM.query();
while(grRITM.next()) {
grRITM.requested_for = user;
grRITM.update();
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-12-2024 01:36 AM
hi @tripu
1. Retrieving the User sys_id:
After the "New Hire Account" catalog item is fulfilled, you'll have a new user record created in the sys_user table. The workflow for this catalog item will be responsible for capturing the sys_id of this newly created user. Here's how:
* Workflow Activity: In the workflow of the "New Hire Account" catalog item, add a "Set Values" activity after the step that actually creates the user record.
* Set Values Script: In the script field of the "Set Values" activity, you'll retrieve the sys_id and store it in the order guide's workflow variable:
// Get the sys_id of the newly created user record
var newHireSysId = current.user.sys_id;
// Set the order guide variable
current.order_guide.variables.new_hire_user_sys_id = newHireSysId;
2. Passing the User sys_id to Other Catalog Items:
Now that you have the new_hire_user_sys_id stored in the order guide's workflow variable, you need to pass it to the other catalog items. Here's the process for each of the remaining catalog items:
* Workflow Activity: Add a "Run Script" activity at the very beginning of the workflow.
* Run Script Script: In the script field of the "Run Script" activity, retrieve the sys_id from the order guide variable and set it to a variable within the catalog item's workflow context:
// Get the sys_id from the order guide variable
var newHireSysId = current.order_guide.variables.new_hire_user_sys_id;
// Set the catalog item's variable (e.g., 'requested_for')
current.variables.requested_for = newHireSysId;
If you like this opinion and your problem is resolved after reviewing and applying it. Please kindly mark this your best answer🌠 OR mark it Helpful ⛑ if you think that you get some insight from this content relevant to your problem and help me to contribute more to this community
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-01-2024 04:25 AM
To everyone who is looking for similar question, I have found the solution to it.
As part of the New Hire Account catalog item, a catalog task will be created which will be worked upon by an IT executive. Create a mandatory variable say, Username (mandatory on closure of the catalog task), hence the IT executive will have to add the Username of the newly created user before closing the task.
Get the value of the variable and do a GlideRecord on the User table to get the sys_id of the newly created user record.
Write a Business Rule in the catalog task on closure of the catalog task table to implement the functionality.
var uName = current.variables.username;
var grUser = new GlideRecord('sys_user');
grUser.addQuery('user_id', uName);
grUser.query();
if(grUser.next()) {
var user = grUser.getUniqueValue();
}
Now the user variable will contain the sys_id of the newly created user. Put this sys_id in the requested_for of the other RITMs of that particular Request.
var req = current.request_item.request;
var grRITM = new GlideRecord('sc_req_item');
grRITM.addQuery('request', req);
grRITM.query();
while(grRITM.next()) {
grRITM.requested_for = user;
grRITM.update();
}