UI action - create requested item from an incident
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-02-2015 02:24 PM
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!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-04-2015 10:33 PM
Hi Dimitar, it depends on what type of relationship are you looking to establish?
a) Is this a many-to-many: 1 RITM can have multiple Incidents and 1 Incident can have associated multiple RITM
b) It this a 1 to 1: 1 RITM is associated to 1 Incident
c) or a 1 to many: 1 Incident is associated multiple RITM?
Thanks,
Berny
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-04-2015 11:58 PM
I am looking forward to create a 1:1 relationship. One RITM generates one Incident. And vice-versa.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-02-2015 09:33 PM
Neither seem to be working for me, still cannot populate the parent.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-02-2015 10:03 PM
Hi Dimitar:
a) would you mind sharing your latest code?
b) also, could you please take a look if the parent field of the RITM is associated to something else? or is it blank (empty)? Perhaps it's getting overwritten by another business value.
Thanks,
Berny
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-04-2015 04:21 AM
OK, so funny thing I noticed was that aft er I create the record (RITM) and I look at the parent field , it has a "i" icon next to it (the mouse over info icon), which means something is assigned there, but I cannot see it.
Actually when I click on the info icon, I am taken to:
Latest code is below:
// update the incident record once, after the function call
current.active = false;
current.state = 9;
current.updateWithReferences();
//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;
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;
newReq.insert();
// now direct to the new Requested Item
gs.addInfoMessage("Incident closed, Requested Item " + newReq.number + " created.");
action.setRedirectURL(newReq);
action.setReturnURL(current);