How to use variable to update Assigned to on RITM?

DChandlerKy
Tera Guru

We are creating a catalog item for our Service Desk to generate General IT Requests. Sometimes they will be assigned to a different group, sometimes they will assign it to themselves and consider it completed (think first call resolution). 

The catalog item includes variables to identify the assignment group and assigned to data. 

In the workflow, through a script activity, I am able to edit the assignment group field on the REQ & RITM with the variable data. I am unable to find a way to update the Assigned To field on the RITM with the corresponding 'assigned to' variable. 

This is what I currently have in the Run Script activity. 

var at = current.getValue(variables.sdGenReq_assginedTo);
gs.log('SD Gen request Assigned to value -current.variables.sdGenReq_assginedTo.user- is ' + at);
current.assigned_to = at;
current.update();

 

I have tried to directly assign the assigned_to field with current.variables.sdGenReq_assignedTo value and that didn't work either. 

If you are wondering - the gs.log reports that the value of the 'at' variable is undefined. 

I have attempted a number of different options to get the value of the variable - the above script just shows my latest attempt.

1 ACCEPTED SOLUTION

If you go the var at route you should still get a sys_id if you assign it like this

var at = current.variables.sdGenReq_assginedTo.toString();

But that's going to be the sys_id of the record on sys_user_grmember, so instead use this

var at = current.variables.sdGenReq_assginedTo.user.toString();
gs.log('SD Gen request Assigned to value is ' + at);
current.assigned_to = at;

View solution in original post

8 REPLIES 8

I still get that var at is undefined. 😞 

Then maybe your variable name is not correct - I would copy and paste it from the variable definition to be certain, and make sure there's not a space before or after the name.

Could you please share the screenshot of the "assigned_to" variable name.

As much as I have copied and pasted. Go back and made adjustments testing/trying things... the variable name was, in fact, missing a character. Sorry and thank you! I think we're in business now.