- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-20-2022 02:39 AM
Hi ,
When a ritm is created, it usually is accompanied with a case. the parent field gets filled with that case and this business rule should run and a comment should get created to the case.
I am trying to get my before insert/update business rule to run, but nothing is appearing on the case record.
conditions: item category is consumables, parent is not empty
at the moment this is the code:
var caseRecord = new GlideRecord('sn_customerservice_case');
caseRecord.addQuery('sys_id', current.parent);
caseRecord.addActiveQuery();
caseRecord.query();
if(caseRecord.next()) {
caseRecord.comment = "Note from Related RITM" + current.number + " Item Category is Consumables";
caseRecord.update();
}
Solved! Go to Solution.
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-20-2022 03:10 AM
Hi
There is a typo:
caseRecord.comments
As per your requirement, it doesn't seem that you want to sync comments to Case from RITM, so you can go for an after Business Rule which runs on Insert/Update.
Rest all looks good.
There could only be a chance that the Case might be getting created a little than RITM and Case record might not be present at that time.
Please mark my answer as correct if this solves your issues!
If it helped you in any way then please mark helpful!
Thanks and regards,
Kartik

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-20-2022 02:53 AM
Hi Carol,
have you tried after insert/update BR ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-20-2022 02:53 AM
Typically when you're updating another record, you would use an after or async business rule and not a before business rule. So you can try changing that, as the case record may not have been "committed" by the time code in your BR runs (you can check if the caseRecord
GlideRecord is a valid record using .isValidRecord() to check if that might be the case). Another issue that I can see is that you're using .comment
, but instead you should be using .comments
as that is the task field you want to update (as sn_customerservice_case extends task)
caseRecord.comments = "Note from Related RITM" + current.number + " Item Category is Consumables";
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-20-2022 03:10 AM
Hi
There is a typo:
caseRecord.comments
As per your requirement, it doesn't seem that you want to sync comments to Case from RITM, so you can go for an after Business Rule which runs on Insert/Update.
Rest all looks good.
There could only be a chance that the Case might be getting created a little than RITM and Case record might not be present at that time.
Please mark my answer as correct if this solves your issues!
If it helped you in any way then please mark helpful!
Thanks and regards,
Kartik
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-20-2022 03:39 AM
Yes i changed to an after while testing and changing to "comments" worked. thanks! 🙂