The CreatorCon Call for Content is officially open! Get started here.

Business rule error message from another table

Brian Lancaster
Tera Sage

I have a business rule running on the rm_scrum_task table. It is an after update that runs as follows.

BrianLancaster_0-1760036521348.png

The code is just to set the story state to work in progess.

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

	// Add your code here
	var gr = new GlideRecord("rm_story");
	gr.get(current.story);
	gr.query();
	if (gr.next()){
		gr.state = -8;
		gr.update();
	}

})(current, previous);

When I save the story task it displays the following message but if I were to just update the story manually to testing I don't get the message. So why am I getting this message when using a business rule to update the story? Is there anyway to prevent this message from displaying just because I using a BR to make the update?

BrianLancaster_1-1760036745458.png

 Conditon 'Condition: current.product.changes() || current.project.changes()' in business rule 'Set Product Backlog Type' on rm_story: test evaluated to null; skipping business rule

 

1 ACCEPTED SOLUTION

aruncr0122
Mega Guru

Hi @Brian Lancaster ,

 

The warning appears because your Business Rule on rm_scrum_task updates the rm_story record using gr.update(), which triggers another BR on the Story table (“Set Product Backlog Type”). That rule uses this condition:
current.product.changes() || current.project.changes().

When your script runs, the story record isn’t fully loaded, so current.product or current.project is null — causing the “evaluated to null” message.


Option 1: Best when you just want to update a field silently (without triggering BRs):

(function executeRule(current, previous) {
var gr = new GlideRecord("rm_story");
if (gr.get(current.story)) {
gr.setWorkflow(false); // prevents other BRs, workflows, etc.
gr.autoSysFields(false); // doesn’t change sys_updated_by/time
gr.state = -8; // Work in Progress
gr.update();
}
})(current, previous);

👉 This will stop the “Set Product Backlog Type” BR from running entirely.

 

Option 2: Load the full record properly

If you do want other rules to run correctly, make sure you remove the unnecessary .query() and use get() only once:

(function executeRule(current, previous) {
var gr = new GlideRecord("rm_story");
if (gr.get(current.story)) {
gr.state = -8;
gr.update();
}
})(current, previous);

The line gr.query(); after a gr.get() is redundant and can mess with record state.This may already fix the null field population issue in some cases.

 

Option 3: Add a null check in the other BR (on rm_story)

If you control the “Set Product Backlog Type” rule, change its condition to avoid null pointer evaluations:
(current.product && current.product.changes()) || (current.project && current.project.changes())

This will ensure it doesn’t fail when either field is empty or undefined.

 

Thanks

View solution in original post

2 REPLIES 2

aruncr0122
Mega Guru

Hi @Brian Lancaster ,

 

The warning appears because your Business Rule on rm_scrum_task updates the rm_story record using gr.update(), which triggers another BR on the Story table (“Set Product Backlog Type”). That rule uses this condition:
current.product.changes() || current.project.changes().

When your script runs, the story record isn’t fully loaded, so current.product or current.project is null — causing the “evaluated to null” message.


Option 1: Best when you just want to update a field silently (without triggering BRs):

(function executeRule(current, previous) {
var gr = new GlideRecord("rm_story");
if (gr.get(current.story)) {
gr.setWorkflow(false); // prevents other BRs, workflows, etc.
gr.autoSysFields(false); // doesn’t change sys_updated_by/time
gr.state = -8; // Work in Progress
gr.update();
}
})(current, previous);

👉 This will stop the “Set Product Backlog Type” BR from running entirely.

 

Option 2: Load the full record properly

If you do want other rules to run correctly, make sure you remove the unnecessary .query() and use get() only once:

(function executeRule(current, previous) {
var gr = new GlideRecord("rm_story");
if (gr.get(current.story)) {
gr.state = -8;
gr.update();
}
})(current, previous);

The line gr.query(); after a gr.get() is redundant and can mess with record state.This may already fix the null field population issue in some cases.

 

Option 3: Add a null check in the other BR (on rm_story)

If you control the “Set Product Backlog Type” rule, change its condition to avoid null pointer evaluations:
(current.product && current.product.changes()) || (current.project && current.project.changes())

This will ensure it doesn’t fail when either field is empty or undefined.

 

Thanks

I used Option 1.

Option 2 did not make a difference still got the error.

Option 3 did not attempt because we try to avoid modifying out the box BRs.