copying fields when converting incident to ritm (requested irm)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-08-2024 12:19 AM
I am converting incident to a Ritm using a ui action button,
i neeed to copy some field fron the incident to the ritm.
everythomg is copied fine except the caller_id to the requested for from the incident to the ritm.
the requested for field stays empty and all the rest is coppied well.
any help to fix his ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-08-2024 12:27 AM
Hello,
You should not create the record directly in Requested item table instead you should add it in cart. Please use the below template to create the SR,
var id = GlideGuid.generate(null); // Generate a new GUID
var cart = new Cart(id); // Instantiate a fresh cart using the random GUID from earlier
var myRitm = cart.addItem('d1399df1874ab9105eb4620d0ebb3517'); // The sys_id of the catalog item to submit
cart.setVariable(myRitm ,'<variable name>', '<variable value>');
//Add the remaining variable like this.
var request = cart.placeOrder();
var sysID=request.sys_id;
var sr = new GlideRecord("sc_req_item");
sr.addQuery("request",sysID);
sr.query();
if(sr.next()){
sr.<field name>= <field value>;
sr.update();
}
If this response was helpful, please consider marking it as 'Helpful' or 'Accept as Solution.'
Your feedback not only supports me, but also helps others in the community who may have similar questions!
Your feedback not only supports me, but also helps others in the community who may have similar questions!
Regards,
Abdul Fathah
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-08-2024 12:42 AM
Hi @ofekg ,
Try below script this is issue with the caller sys_id , put logs current.caller_id and check.
ritm.requested_for = current.caller_id.toString();
Mark it as helpful and solution proposed if it serves your purpose.
Thanks,
Anand
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-08-2024 01:57 AM
sadly, didnt work for me, maybe you got different idea?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-08-2024 01:54 AM
Hello @ofekg
I have reviewed the script for creating an RITM from an Incident, and it seems to be working correctly. I tested the provided code in my Personal Developer Instance (PDI), and the requested_for field is successfully populated with the value from caller_id.
The relevant code snippet is as follows:
var ritm = new GlideRecord('sc_req_item');
ritm.initialize();
ritm.cat_item = catalogItemSysID;
// Map Incident fields to RITM fields
ritm.requested_for = current.caller_id;
ritm.short_description = current.short_description; // Incident Short Description → RITM Short Description
ritm.description = current.description; // Incident Description → RITM Description
ritm.assignment_group = current.assignment_group; // Incident Assignment Group → RITM Assignment Group
ritm.assigned_to = current.assigned_to; // Incident Assigned To → RITM Assigned To
ritm.priority = current.priority || 4; // Default Priority to Low
ritm.state = 1; // Set State to Open
ritm.u_task_type = 'catalog task';
// Map custom fields/variables to RITM fields
ritm.variables.please_describe_how_can_we_help_you = current.description; // Incident Description to RITM variable
ritm.variables.incident_reference_number = incNum; // Store the Incident number for reference (custom variable)
// Insert the RITM record
var ritmSysID = ritm.insert();
The script appears functional, so there may be another factor in your instance preventing the requested_for field from being populated. You might want to check the following:
- Ensure that the caller_id field in the Incident record is populated with a valid sys_user reference.
- Verify if there are any business rules, scripts, or access controls in your instance affecting the RITM creation process.
- Check if the catalog item associated with the RITM has specific conditions or constraints impacting field population.
"If you found my answer helpful, please like and mark it as an "accepted solution". It helps others find the solution more easily and supports the community!"
Thank You
Juhi Poddar