5 Replies · Latest reply on Jun 22, 2017 1:17 AM by andy dufresne

    How to create Request from Incident and Incident from Request?

      Hi,

       

      This is the requirement.

       

      1. Create a Request ticket from an Incident. When 'Create Request' is clicked, it should trigger the current Incident to canceled state and create a request ticket with the details provided in the Incident form.

      2. Also, vice versa. Create a Incident ticket from Request. When 'Create Incident' is clicked on the Request form, it should trigger the current request to canceled state and create an Incident ticket with the details provided in the request form. Has anyone does this?

       

      Can anyone put me in the right direction and tell how to do this?

       

      Thanks,

      Rajini

      Thanks,

      Rajini

        • Re: How to create Request from Incident and Incident from Request?
          Michael Fry

          Out of the box in Helsinki, there is a UI Action on Incident table named Create Request.

          1 of 1 people found this helpful
          • Re: How to create Request from Incident and Incident from Request?
            rajinis

            Michael,

             

            I too saw that, but it is taking me to the catalog landing page.

            I want that UI Action to create the Request ticket.

            Thanks,

            Rajini

              • Re: How to create Request from Incident and Incident from Request?
                jued0001

                Here is the UI Action we currently have, you'll need to modify the script to your needs:

                 

                 

                //Client-side 'onclick' function

                function IncWarning() {

                  var answer = confirm("Please confirm Incident to Request Action.");

                  if (answer == false) {

                  return false;

                  }

                  gsftSubmit(null,g_form.getFormElement(),'cancel_inc_create_req');

                }

                 

                 

                //Code that runs without 'onclick'

                //Ensure call to server-side function with no browser errors

                 

                 

                //if (typeof window == 'undefined')         //serverCancelPrj();

                 

                 

                createCart();

                function createCart() {

                  var cart = new Cart();

                  var item = cart.addItem('ea8f4a5e4fdab680e52350ee0310c7e4');

                  cart.setVariable(item, 'requested_for', current.caller_id.sys_id.toString());

                  cart.setVariable(item, 'requested_by', current.caller_id.sys_id.toString());

                  cart.setVariable(item, 'short_description', current.short_description);

                  cart.setVariable(item, 'phone', current.u_current_phone);

                  cart.setVariable(item, 'location', current.location);

                  cart.setVariable(item, 'description', 'Converted to Request from: ' + current.number + '\n\n' + "Incident Description: " + current.description + '\n\n' + current.comments.getJournalEntry(3) + '\n\n' + current.work_notes.getJournalEntry(3));

                 

                 

                // cart.setVariable(item, 'assignment_group', current.assignment_group);

                // cart.setVariable(item, 'assigned_to', current.assigned_to);

                 

                  var rc = cart.placeOrder();

                 

                 

                  current.close_code = 'Not Solved (is a Request)';

                  current.close_notes = 'Opened in Error, converting to Misc Request';

                  current.comments = 'Converted Incident to Request: ' + rc.number;

                  //sets the REQ on the parent INC

                  current.u_request = rc.sys_id.toString();

                  current.reassignment_count = 1;

                  current.state = 6;

                 

                  GlideSysAttachment.copy('incident', current.sys_id, 'sc_request', rc.sys_id);

                  //Update saves incidents before going to the catalog homepage

                 

                  current.update();

                 

                 

                  var fp = new GlideRecord('sc_request');

                  fp.addQuery('sys_id', '=', rc.sys_id);

                  fp.query();

                  while (fp.next()){

                  fp.parent = current.sys_id;

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

                  fp.cmdb_ci = current.u_application;

                  fp.update();

                  }

                  action.setRedirectURL(rc);

                }

                1 of 1 people found this helpful
              • Re: How to create Request from Incident and Incident from Request?
                rajinis

                Thank you so much. I will try this and post my comments soon.

                Thanks,

                Rajini