Convert IR to PR
Cireson Web Portal Extension - Convert to Problem Task
From the Service Manager Console, you can open an Incident and use the “Create Problem” task to automatically create an associated Problem. The Cireson Web Portal doesn’t allow this capability out-of-the-box. If an Incident was created and needed to be converted into a Problem, you would have to create a new Problem and then add the Incident as a Related Item.
Function - Form Task
This function adds the “Convert to Problem” task to the Incident Form.
Function – convertIRtoPR
This function is the base function for the task. It defines the problem class ID and then makes a call to the Web API to pull back all available problem templates. It then sends those templates forward to the ‘loadTemplates’ function.
Function - loadTemplates
This function first loads the custom HTML Template “ext_ConvertIRtoPR_template.html”. It then adds the Problem Templates to the drop-down within the HTML Template. Next it creates an OK button and adds logic around the click of that button. It creates a variable that is assigned the value of the selected item in the drop-down. When OK is clicked, it calls the createProblem function and sends the selected item’s templateid and then closes the window. There is also a Cancel button created that just closes the window when clicked. The actual loading of the Window and Binding of the above logic occurs in the var _vmWindow section.
Function - createProblem
This function receives the templateid from the loadTemplates function and sets a variable for the logged in user’s User ID. It then makes a call to the Web API to create a projection by the templateid and the User ID. This is the part that creates the Problem. If the call is successful, it copies the Title, Description, Contact Method, Affected User, all related WorkItems, all related Configuration Items, and Created By User from the Incident to the Problem. It also creates a relationship between the incident and the problem. It then commits/posts the data and re-directs the user to the newly created.
Function – setIRresolved
This function is called from the createProblem function once it successfully creates the new Problem. It receives the view model as a parameter and then sets all of the relevant information needed to set an Incident to resolved. Once it has set all of the parameters, it commits/updates the changes using the Web API. In order to update a work item you need to send the Web API the original work item JSON object and the new (current) JSON Object that contains the updated values.
How to use it
1. Open an Incident, and click “convert to problem” from the Tasks on the right.
Select the Template you would like to apply to
the newly created Problem and then click OK.
Once created, you will be redirected to the
newly created ticket.
How to install it
- Copy the contents of the ‘ext_ConvertIRtoPR.js’ file to the ‘custom.js’ file (located under the CiresonPortal\CustomSpace folder) beneath any other content in the file. Then add the following code snippet to the top of the ‘custom.js’ file.
- Copy the ‘ext_ConvertIRtoPR_template.html’ file to the CiresonPortal\CustomSpace folder.
- Refresh your browser and the new task should appear when an Incident is open.
Download the attached .zip file below.