Problem
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-04-2024 09:24 PM
When creating a problem ticket if the urgency and impact are high, I need to generate automatic ptask with some fields to auto populate and then the ticket should be created
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-04-2024 09:30 PM
Hi @Anantha27 ,
You can write a onAfter business rule on problem table with condition if the urgency and impact are high and it should run on Insert only and in script you can use GlideRecord API to create the problem_task.
Thanks and Regards,
Saurabh Gupta
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-04-2024 09:34 PM - edited ‎11-04-2024 10:13 PM
Use Flow Designer for this.
It is easier to do and you dont have to write any code.
Thanks
Deepak
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-04-2024 09:43 PM
Hi @Anantha27
To automate the creation of a problem ticket in ServiceNow when both urgency and impact are set to high, you can utilize business rules and script actions. Example:
- Define the Conditions with Urgency and Impact fields are set to high.
- Create a Business Rule for problem table with
- Condition: current.urgency == '1' && current.impact == '1' ​
- Define a Script for Creating the PTask:
(function executeRule(current, previous /*null when async*/) {
// Create a new PTask record
var ptask = new GlideRecord('ptask'); // Replace 'ptask' with the actual table name for PTask
ptask.initialize();
// Populate fields with desired values
ptask.short_description = 'PTask for Problem: ' + current.number;
ptask.problem = current.sys_id; // Link to the created problem ticket
ptask.state = 'New'; // Set initial state as New
// Add any additional fields you want to auto-populate
ptask.assigned_to = current.assigned_to; // Example: Assign to the same user as the problem ticket
// Insert the PTask record into the database
ptask.insert();
})(current, previous);
- Ensure that your user roles have permission to create records in both the Problem and PTask tables.
Thanks, and Regards
Vishaal
Please mark this response as correct or helpful if it assisted you with your question.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-04-2024 09:59 PM
Hi @Anantha27 ,
You can create After Insert BR with below Condition & Script to create a Problem Task if the Problem is created with Urgency & Impact is high:
Script: