how to update Requested for and Opened by on sc_req_item table

Ram050670
Tera Guru

Hi All,

how to update Requested for and Opened by on sc_req_item table in workflow of a catalog item

var requestedFor = current.varaibles.req_for;

var openedby = current.opened_by;

above are the values from current RITM and need to update on the new RITM after this request

 

var reqItem = new GlideRecord('sc_req_item');
reqItem.get(sys_id);
reqItem.requested_for = requestedFor;
reqItem.opened_by = openedby;
reqItem.update();

 

i am trying to use this but not able to update the record.

 

 

 

11 REPLIES 11

Hi @Ram050670 ,
The request script updates the "opened by" and Requested For  user for the entire request, which will then apply to all the associated RITMs (sc_req_item) check the fields exactly dot walked.
If you want to change the "opened by" user for a specific RITM, you'll need to make the change at the request level (sc_request), and the change will reflect on all associated RITMs. You cannot directly update the opened_by field on an individual RITM.


var sys_id = current.sys_id;
var requestedForSysID = current.variables.requested_for.toString();
var openedBySysID = current.opened_by.toString();
var reqItem = new GlideRecord('sc_req_item');
if (reqItem.get(sys_id)) {
reqItem.requested_for = requestedForSysID;
reqItem.update();var request = new GlideRecord('sc_request');
if (request.get(reqItem.request)) {
request.opened_by = openedBySysID;
request.update();
}
}
Thanks,

Anand

i see...basically the Opened by on RITM is from task table, this is the only thing to set now.

Naneen_0-1698776152342.png

 

still same not working!

Leonardbrit
Tera Contributor

The phrase could be seen as satirical or ironic, playing on the idea of using the most extreme and unsettling concept, nuclear war, in a calm and relaxing context: https://essayusa.com/  It's essential to note that the juxtaposition is likely intended for humor or shock value and not as a genuine recommendation for studying or relaxation.

Danish Bhairag2
Tera Sage
Tera Sage

Hi @Ram050670 ,

 

Can u try this code n check if it updates:

 

var sys_id = current.sys_id;

    var requestedFor = current.variables.requested_for; 

    var openedby = current.opened_by;

var reqItem = new GlideRecord('sc_req_item');

if(reqItem.get(sys_id)){

reqItem.request.requested_for = requestedFor;

reqItem.opened_by = openedby;

reqItem.update();

}

 

Thanks,

Danish