Need to set the ticket status as closed complete

Ramya SL
Tera Contributor

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.

 

 

 

6 REPLIES 6

vermaamit16
Kilo Patron

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

Thanks and Regards
Amit Verma

This code is written inside workflow editor script tag. Yes I have mapped the workflow to this catalog item as shown in SS.

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

Thanks and Regards
Amit Verma

Not applicable

Hi Ramya,

Try using "Set values" activity from the utilities tab in the flow.