- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-19-2023 04:31 AM
Hi, we are working on SLA related to task , when the parent case state is awaiting info we need to set the SLA for related case task to 'Paused' state.
since only the case record is getting updated with the state the SLA for case task remains unchanged.
with the update to any field in the case task record we are able to see the correct state of SLA .
so to update the case task we have written a business rule to update the work notes, below is the script
we are not able to see any update in case task record , please let us know what are we missing here.
Thanks in advance
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-20-2023 12:16 AM - edited 01-20-2023 12:17 AM
Create Before Update Business Rule with condition state changes to awaiting info or state changes to open & try below code snippet.
(function executeRule(current, previous /*null when async*/ ) {
var caseTask = new GlideRecord("sn_customerservice_task");
caseTask.addQuery("parent", current.sys_id);
caseTask.query();
while (caseTask.next()) {
caseTask.work_notes = "Testing";
caseTask.update();
}
})(current, previous);
If your question is solved, please close the topic by marking my answer "Accept as Solution". This will help others searching for a similar question and will remove the topic from the unsolved list.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-20-2023 03:40 AM
Hi @Dipali Pawar2 ,
Please try @Omkar Ranjane solution, if you still unable to get the solution let me know
Regards,
Kalyan
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-21-2023 04:17 AM - edited 01-21-2023 06:11 AM
Hello @Omkar Ranjane .
Thanks for the code, worked like a charm!
I have a similar requirement and the case task is getting updated on change of state. One additional implementation which we are looking is to get the current state of the parent case.
I tried using
current.top_task.getDisplayValue('state');
current.parent.getDisplayValue('state');
Both are bringing undefined value, Kindly help on this
Below is the script and screen shot:
(function executeRule(current, previous /*null when async*/ ) {
var caseTask = new GlideRecord("sn_customerservice_task"); //Gliding Case Task
caseTask.addQuery("parent", current.sys_id); //Checking if Case task has parent
caseTask.query();
while (caseTask.next()) { //if case task exist , updating work notes
var parent_case_state =current.top_task.getDisplayValue('state');
caseTask.work_notes = "Case State updated to" + parent_case_state;
caseTask.update();
}
})(current, previous);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-21-2023 06:07 AM - edited 01-21-2023 06:10 AM
Hello @Omkar Ranjane @kalyan13
I have figured out the error.
Below is the code and snapshot
(function executeRule(current, previous /*null when async*/ ) {
var caseTask = new GlideRecord("sn_customerservice_task"); //Gliding Case Task
caseTask.addQuery("parent", current.sys_id); //Checking if Case task has parent
caseTask.query();
while (caseTask.next()) { //if case task exist , updating work notes
var parent_case_state = current.getDisplayValue('state');
caseTask.work_notes = "Case state has been updated to" + " " + parent_case_state;
caseTask.update();
}
})(current, previous);
Thanks for the inputs
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-19-2023 07:05 AM - edited 01-19-2023 07:05 AM
In your script you are setting the work_notes of the current record instead of myObj (child cases). Also you have to update the records using myObj.update().
Also in your query you are missing the relationship to the parent so you would update all cases in state 10,18.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-19-2023 09:31 PM
Hi Sebastian , thank you for your reply .
Got your point , could you please elaborate how to create relationship between parent and child.
we tried parent.case unfortunately missing out the logic on reaching of the parent of the case task .
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-19-2023 09:49 PM
Hi @Dipali Pawar2
Please try below BR script
var myObj = new GlideRecord('sn_customerservice_task);
myObj.addQuery('sys_id', parent_case_record_field); // here parent_case_record_field which store parent case number on sn_customerservice_task table.
myObj.query();
if (myObj.next()){
myObj.work_note = "Testing";
myObj.update();
}
let us know if any issue occur.
If I could help you with your Query then, please hit the Thumb Icon and mark as Correct !!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-19-2023 10:23 PM
Hi @Sonu Parab
Thanks for the response, we tried using your script, but unfortunately it doesn't seem to work, when we update any fields in the case, the worknotes in case task are not getting updated..
We tried a sample filter condition of when Case Category changes, the worknotes of the case task related to that case should be updated.
Kindly let us know what are we missing here