UI action - create requested item from an incident

mitzaka
Mega Guru

Hi SNC,

I want to create a RITM from an incident, using an UI action. Below is my code, my questions are in red:

createRITM();

// update the record once, after the function call

current.active = false;

current.state = 9; //setting it to closed state

current.updateWithReferences();

  function createRITM() {               //create the new Requested Item Record

  var newReq = new GlideRecord("sc_req_item");

  newReq.initialize();

  newReq.opened_by=current.opened_by;

  newReq.assignment_group='4e868fe1508381002cf0066911d9982c';

  newReq.cmdb_ci=current.cmdb_ci;

  newReq.u_business_service=current.u_business_service;

  newReq.u_customer_defined_urgency=current.u_customer_defined_urgency;

  newReq.variables=current.variables; //I am storing catalog item variables in a formatter, called Requested Item Variable Editor, and I wanted to transfer the variables from the incident into the RITM, but it does not happen

  newReq.description=current.description;

  newReq.short_description=current.short_description;

  newReq.contact_type='2';

  newReq.state=current.state;

  newReq.priority=current.priority;

  newReq.watch_list=current.watch_list.getDisplayValue().toString();

  newReq.parent=current.number; //I can't get this working - cannot populate the Parent field in the RITM with the ID of the incident

  newReq.insert();

  // now direct to the new Request

  gs.addInfoMessage("Incident closed, Requested Item "   + newReq.number + " created.");

action.setRedirectURL(newReq);

action.setReturnURL(current);

  }

Would you throw a sanity check eye on this?

Thanks!

16 REPLIES 16

Above code was for copying variables form INC to RITM. Have you achieved this?



If yes and now you are trying vice-versa then please let us the code your are using for this i.e. copy variables form RITM to INC.


I tried with this code to convert an incident to a RITM, but when I look in my Requested item variable editor tab, there is nothing carried over.