Need to set the ticket status as closed complete
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-01-2024 01:32 AM
Hi all,
I created a catalog item to add new user.
var rec = new GlideRecord('sys_user');
rec.initialize();
rec.first_name=current.variables.first_name;
rec.last_name=current.variables.last_name;
rec.user_name=current.variables.user_id;
rec.department=current.variables.department;
rec.opened_at=current.variables.start_date;
rec.state=current.variables.ticket_status;
rec.insert();
Now I need to extend my above code where I have to set the ticket status as closed complete automatically for both REQ and RITM whenever a new user is created.
And I need to set a description field as "New User Onboarding"
short description as "New user account created" and also it should contain userid and start date details in this itself.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-01-2024 01:42 AM
Hi @Ramya SL
Are you using this code in a script include ? Also, do you have a flow mapped to the catalog item ?
Thanks & Regards
Amit Verma
Please mark this response as correct and helpful if it assisted you with your question.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-01-2024 02:11 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-01-2024 02:30 AM
As a next step in your workflow, you can put a validation whether the user is created successfully or not using if condition. If user created successfully, make use of a run script again to close the RITM or RITMs being generated by your workflow followed by Req. Refer below code and try :
var ritm = new GlideRecord('sc_req_item');
ritm .addQuery('request', current.sys_id);
ritm .query();
while(ritm .next()){
ritm .state = 3; // State value for "Closed Complete"
ritm .update();
}
// Close Request
var req = new GlideRecord('sc_request');
req.addQuery('sys_id',current.sys_id);
req.query();
if(req.next()){
req.state = 3;
req.update();
}
Thanks & Regards
Amit Verma
Please mark this response as correct and helpful if it assisted you with your question.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-01-2024 02:21 AM
Hi Ramya,
Try using "Set values" activity from the utilities tab in the flow.