When incident task is attached to incident make u_open_incident_task to true
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-19-2024 07:45 AM
Hello Team,
I need help here ASAP
I have created one custom field called as u_open_incident_task field on incident table. so whenever incident task is attached to the incident then make u_open_incident_task to true.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-19-2024 07:59 AM
Hi @rmishra4395 - What's the use case? You could create a business rule on incident_task...after insert, when Incident is not empty, update the incident referenced in 'incident'.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-19-2024 08:18 AM - edited 11-19-2024 11:18 AM
You can use a business rule, as mentioned above, that runs on the incident_task table. Defined as shown below
And the script in the Advanced tab:
(function executeRule(current, previous /*null when async*/) {
// Add your code here
// Update the incident field u_open_incident_task
var inc = new GlideRecord('incident');
inc.addQuery('sys_id', current.incident.toString());
inc.query();
if (inc.next()) {
inc.u_open_incident_task = 'true';
inc.update();
}
})(current, previous);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-19-2024 08:43 AM
Alternatively, the following would be a bit more efficient:
(function executeRule(current, previous /*null when async*/ ) {
// Retrieve the referenced incident record
var inc = current.incident.getRefRecord();
if (inc.isValidRecord()) {
// Check if the field is not already true
if (inc.u_open_incident_task !== true) {
inc.u_open_incident_task = true; // Use Boolean value directly
inc.update();
}
}
})(current, previous);