Convert incident to request.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-12-2024 02:57 AM
Requirement: For a particular workspace I have to convert incident to request using UI Action and when that incident is converted to request the state of that incident should be cancelled and work note will be populated with 'this incident is converted to request'.
How can I achieve it? Can anyone please help me out, it is urgent?
Thanks in advance.
Regards,
Abhisek Chattaraj.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-12-2024 03:01 AM
Hi @abhisek
OOTB we can create request from Inc ,
You can chekc this code and add your code to cancel the incident.
If my response proves useful, please indicate its helpfulness by selecting " Accept as Solution" and " Helpful." This action benefits both the community and me.
Regards
Dr. Atul G. - Learn N Grow Together
ServiceNow Techno - Functional Trainer
LinkedIn: https://www.linkedin.com/in/dratulgrover
YouTube: https://www.youtube.com/@LearnNGrowTogetherwithAtulG
Topmate: https://topmate.io/atul_grover_lng [ Connect for 1-1 Session]
****************************************************************************************************************
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-12-2024 03:08 AM
I need to do it for a particular workspace which is in a different application scope using UI action.
Thanks&Regards,
Abhisek Chattaraj.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-12-2024 03:41 AM
Okay, my intention was to tell you, you can look this UI action code and use.
If my response proves useful, please indicate its helpfulness by selecting " Accept as Solution" and " Helpful." This action benefits both the community and me.
Regards
Dr. Atul G. - Learn N Grow Together
ServiceNow Techno - Functional Trainer
LinkedIn: https://www.linkedin.com/in/dratulgrover
YouTube: https://www.youtube.com/@LearnNGrowTogetherwithAtulG
Topmate: https://topmate.io/atul_grover_lng [ Connect for 1-1 Session]
****************************************************************************************************************
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-12-2024 03:23 AM
Hi @Abhisek ,
You can apply below points as per scenario, May be it will working for your scenario
Certainly! To achieve this behavior in ServiceNow, you can create a custom UI action that converts an incident to a request and performs the necessary actions. Here are the steps:
Create a UI Action:
- Navigate to “System Definition” > “UI Actions.”
- Click “New” to create a new UI action.
- Set the following properties:
- Name: Choose a descriptive name (e.g., “Convert to Request”).
- Table: Select “Incident” (or the appropriate table where incidents are stored).
- Action name: Choose an action name (e.g., “convert_to_request”).
- Client: Set to true (to execute on the client side).
- Onclick script:JavaScript
// Assuming 'incident' is the current incident record var gr = new GlideRecord('sc_request'); gr.initialize(); gr.short_description = 'Converted from incident: ' + incident.number; gr.insert(); // Update the incident state to 'Cancelled' incident.state = 8; // 'Cancelled' state incident.update(); // Add a work note var workNote = 'This incident has been converted to a request.'; var notes = new GlideRecord('sys_journal_field'); notes.initialize(); notes.element = 'work_notes'; notes.value = workNote; notes.type = 'work_notes'; notes.name = gs.getUserName(); notes.sys_id = gr.sys_id; notes.insert(); // Redirect to the newly created request gs.addInfoMessage('Incident converted to request. Request number: ' + gr.number); action.setRedirectURL('/sc_request.do?sys_id=' + gr.sys_id);
AI-generated code. Review and use carefully. More info on FAQ.
- Save the UI action.
Test the UI Action:
- Go to an incident record.
- Click the newly created UI action (“Convert to Request”).
- Verify that a new request is created, the incident state is set to “Cancelled,” and the work note is added.
Remember to adjust field names and table names according to your specific ServiceNow instance
If this is helpful for you, Please mark Helpful and Correct solution
Thanks & Regards
Adarsh Verma