- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-19-2020 12:26 AM
Hello everybody,
I d like to know how to push the requested for variable on the sc_req_item.requested for field
my requested for variable is in set variable I don't know if it can be trouble.
I already searched in the community and it's not working
https://community.servicenow.com/community?id=community_question&sys_id=00c00b65db98dbc01dcaf3231f9619b6&view_source=searchResult
I created a BR on before based on my catalog element and it's working for the other field (self service,telephone and description)
(function executeRule(current, previous /*null when async*/) {
// Add your code here
current.requested_for=current.variables.requested;
current.contact_type='self-service';
current.u_t_l_phone_pro=current.variables.telephone;current;
current.description=current.variables.description;
})(current, previous);
Thanks a lot for your help
Have a good day
Barbara CS
Solved! Go to Solution.
- Labels:
-
Service Catalog
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-19-2020 10:43 PM
you can achieve this from workflow.
In the workflow, use Run script and try below code
var req = new GlideRecord("sc_request");
req.addQuery("sys_id", current.request);
req.query();
if(req.next()) {
req.requested_for = current.variables.<variable name>;
req.update();
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-19-2020 12:40 AM
Hi,
There does not exists any Requested for field on RITM it is on REQ table.
Replace
current.requested_for=current.variables.requested;
with
current.request.requested_for=current.variables.requested;
for a check

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-19-2020 12:42 AM
Above would work if you are using it in Run script activity of workflow.
For Business rule use below.
(function executeRule(current, previous /*null when async*/) {
// Add your code here
//Goes to REQ table to update reqeusted for which will be reflected at RITM level
var getreq=new GlideRecord('sc_request');
getreq.addQuery('sys_id',current.request);
getreq.query();
if(getreq.next())
{
getreq.requested_for=current.variables.requested;
getreq.update();
}
current.contact_type='self-service';
current.u_t_l_phone_pro=current.variables.telephone;current;
current.description=current.variables.description;
})(current, previous);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-19-2020 10:23 PM
Hello and thanks for your help
it s not working on my database current.request.requested_for=current.variables.requested.
On the following screen with your business rule I haven't got any value in requested for in the screen order status
but when i use this script in business rules before there's a the good value in "Requested for" it'working but my other variables are not updated (phone, description) on RITM
(function executeRule(current, previous /*null when async*/) {
// Add your code here
if(current.variables.requested){
var grREQ = new GlideRecord('sc_request');
grREQ.get(current.getValue('request'));
grREQ.setValue('requested_for', current.variables.requested);
grREQ.update();
gs.log(grREQ, " Requested For");
}
current.contact_type='self-service';
current.u_t_l_phone_pro=current.variables.telephone;current;
current.description=current.variables.description;
})(current, previous);
I don't know where is the mistake on my param or that solution seems to be good but my other variables are not updated I have to learn about developpment too
Thank for your help
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-19-2020 10:43 PM
you can achieve this from workflow.
In the workflow, use Run script and try below code
var req = new GlideRecord("sc_request");
req.addQuery("sys_id", current.request);
req.query();
if(req.next()) {
req.requested_for = current.variables.<variable name>;
req.update();
}