add comment to parent when RITM gets created

Carol13
Kilo Expert

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();

}

1 ACCEPTED SOLUTION

Kartik Sethi
Tera Guru
Tera Guru

Hi @Carol 

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

View solution in original post

6 REPLIES 6

Chetan Mahajan
Kilo Sage
Kilo Sage

Hi Carol,

                have you tried after insert/update BR ? 

Nick Parsons
Mega Sage

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 .commentas 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";

 

 

 
 
 

Kartik Sethi
Tera Guru
Tera Guru

Hi @Carol 

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

Yes i changed to an after while testing and changing to "comments" worked. thanks! 🙂