diff --git a/Server-Side Components/Business Rules/Create a task based on field/Creating_Task_Based_on_Field_Value.js b/Server-Side Components/Business Rules/Create a task based on field/Creating_Task_Based_on_Field_Value.js new file mode 100644 index 0000000000..877424af88 --- /dev/null +++ b/Server-Side Components/Business Rules/Create a task based on field/Creating_Task_Based_on_Field_Value.js @@ -0,0 +1,12 @@ +(function executeRule(current, previous) { + // Check if the priority is critical and a follow-up task doesn't already exist + if (current.priority == 1 && !current.u_follow_up_task_created) { // Assuming 1 is critical priority, and u_follow_up_task_created is a custom boolean field + var grTask = new GlideRecord('sc_task'); + grTask.initialize(); + grTask.short_description = "Follow-up for Critical Incident: " + current.number; + grTask.parent = current.sys_id; + grTask.insert(); + current.u_follow_up_task_created = true; // Mark that a task has been created + current.update(); // Update the incident to reflect the task creation + } +})(current, previous); \ No newline at end of file diff --git a/Server-Side Components/Business Rules/Create a task based on field/Readme.md b/Server-Side Components/Business Rules/Create a task based on field/Readme.md new file mode 100644 index 0000000000..4b220a80b5 --- /dev/null +++ b/Server-Side Components/Business Rules/Create a task based on field/Readme.md @@ -0,0 +1,3 @@ +Creating a Task Based on a Field Value: + +This Business Rule runs "after" an insert or update to an Incident to automatically create a new "Follow-up Task" if the "Priority" is set to "Critical." diff --git a/Server-Side Components/Business Rules/updating problem records/Readme.md b/Server-Side Components/Business Rules/updating problem records/Readme.md new file mode 100644 index 0000000000..30900af0a3 --- /dev/null +++ b/Server-Side Components/Business Rules/updating problem records/Readme.md @@ -0,0 +1 @@ +If the incident status is chnaged to inprogress corresponding problem state is chnaged to in progresss. diff --git a/Server-Side Components/Business Rules/updating problem records/updating_problem_record.js b/Server-Side Components/Business Rules/updating problem records/updating_problem_record.js new file mode 100644 index 0000000000..a62fc329dc --- /dev/null +++ b/Server-Side Components/Business Rules/updating problem records/updating_problem_record.js @@ -0,0 +1,12 @@ +(function executeRule(current, previous) { + // Check if the state changed to "In Progress" + if (current.state.changesTo(2)) { // Assuming 2 is the value for "In Progress" + var grProblem = new GlideRecord('problem'); + grProblem.addQuery('incident', current.sys_id); + grProblem.query(); + while (grProblem.next()) { + grProblem.state = 2; // Assuming 2 is the value for "Work in Progress" + grProblem.update(); + } + } +})(current, previous); \ No newline at end of file