Need Help with a ServiceNow Business Rule

Olga -Maria
Tera Contributor

I have a ServiceNow business rule that is supposed to set the "warranty_expiration" field of a CMDB CI item based on the end date of a related contract. The script runs without errors, and I can see the log entries indicating that it should be updating the field.

However, the field is not being updated as expected.

I've double-checked the script, field and table names, permissions, and conditions, but I can't figure out why it's not working.

Could someone please help me troubleshoot this issue and provide suggestions on what might be going wrong? Thank you in advance!


Business rule runs on Insert and Update : 

(function executeRule(current, previous /*null when async*/ ) {


current.ci_item.warranty_expiration = new GlideDateTime(current.contract.ends.getValue());

1 ACCEPTED SOLUTION

@Olga -Maria 

when is the BR running?

you are not using the script I shared above

var rec = new GlideRecord('cmdb_ci');
if(rec.get(current.ci_item)){
	rec.warranty_expiration = new GlideDateTime(current.contract.ends);
	rec.update();
}
Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

View solution in original post

5 REPLIES 5

Ankur Bawiskar
Tera Patron
Tera Patron

@Olga -Maria 

you cannot set dot walk field

you need to query and then update

var rec = new GlideRecord('cmdb_ci');
if(rec.get(current.ci_item)){
	rec.warranty_expiration = new GlideDateTime(current.contract.ends);
	rec.update();
}

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

Olga -Maria
Tera Contributor

@Ankur Bawiskar 
The Business Rule works on the Contract CI table, an m2m table for cmdb_ci and contracts. Does this make a difference? Because it does not work.

@Olga -Maria 

please ensure you are using correct fields.

Please share the field names and BR screenshot

Did you debug it?

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

Olga -Maria
Tera Contributor

businessRULE.png

@Ankur Bawiskar I hope this helps. 

Thank you