
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-01-2018 08:27 AM
I need to change/set the requested_for field in a Requested Item so the Tasks emails contain the proper information.
I've made a script and placed it in both a Run Script as well as the Advanced tab for an SC_Task in a workflow.
I used the following script which appears to work (the log shows the right information), but the form still has the wrong user name:
current.requested_for = current.variables.Request_for_User;
current.requested_by = current.variables.Request_for_User;
current.update();
gs.log("FIRST RUN SCRIPT: Current Number/request_for/requested_by:" +current.number+'/'+current.requested_for.getDisplayValue()+'/'+current.requested_by.getDisplayValue());
Any suggestions?
Mike
Solved! Go to Solution.
- Labels:
-
Best Practices
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-01-2018 09:03 AM
As it's on the request table you can try
var req = new GlideRecord('sc_request');
req.get(current.request);
req.requested_for = current.variables.requested_for_user; // or whatever the variable is called
req.update();

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-01-2018 02:41 PM
Any reason you want to do via workflow versus BR?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-01-2018 02:59 PM
I'd prefer the Workflow Run Script as it is local to that workflow.
I'll try it in a BR tomorrow and report results back.
Thanks!

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-08-2018 11:04 AM
Scott's script worked.
Now I'm trying to get the Task Email Notification to display the correct name.
It uses caller_id, but that displays nothing - as does requested_for:
Caller: ${caller_id} ${requested_for}
Caller email: ${caller_id.email}
Caller phone: ${caller_id.phone}
Any ideas?
MC
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-08-2018 11:13 AM
Try using ${request.caller_id} and ${request.requested_for}. If the task is generated by the RITM, you might need to use ${parent.request.caller_id} and ${parent.request.requested_for}.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-08-2018 11:50 AM
That got it!
parent.request.requested_for worked - as did request.request.requested_for
I tried parent.requested_for as I was certain (for the email notification template) I was in TASK and not the sc_req_item.
Thank you!
Mike