Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

Dot walk inside business rule to set value

sndev1099
Giga Expert

Hello, 

I need some assistance setting a field inside my BR. 

The value of Event type 2 needs pushing to a field on the user form. Can I do that by dotwalking to it?

find_real_file.png

find_real_file.png

 

Here is my code:

(function executeRule(current, previous /*null when async*/) {
	
	var event = new GlideRecord('u_insider_risk_population_management');
	event.addQuery('x_lbg_insider_risk_eventtype1', 'Vetting');
	event.addQuery('x_lbg_insider_risk_eventoutcome2','Complete');
	event.query();
	
	while (event.next()) {
		
		//gs.info("AB 30_06 " + event.getRowCount());
		event.setValue(current.u_user.x_lbg_insider_risk_vetting_type, current.x_lbg_insider_risk_eventtype2);
		event.update();
	}

})(current, previous);
1 ACCEPTED SOLUTION

MrMuhammad
Giga Sage

No, you cannot as you need to force update the value on the user table but with dot-walking you won't have access to user table object that help you with updating the value after setting that. 

You can do something like this

while(event.next()){
 var userGr = current.u_user.getRefRecord(); // get users glide record.

 userGr.setValue('x_lbg_insider_risk_vetting_type', current.x_lbg_insider_risk_eventtype2);
 userGr.update();

}

 


Please mark this correct & helpful if it answered your question.

 

Thanks & Regards,
Sharjeel

 

Regards,
Muhammad

View solution in original post

6 REPLIES 6

Shane J
Tera Guru

You can't dotwalk to a value on a table to set it.  You'll need to do a GlideRecord query and update the record on the table directly.

Ok thanks Shane. Are they any limitations to doing 2 gliderecord queries in one business rule?

Not that I'm aware of.  😃

MrMuhammad
Giga Sage

No, you cannot as you need to force update the value on the user table but with dot-walking you won't have access to user table object that help you with updating the value after setting that. 

You can do something like this

while(event.next()){
 var userGr = current.u_user.getRefRecord(); // get users glide record.

 userGr.setValue('x_lbg_insider_risk_vetting_type', current.x_lbg_insider_risk_eventtype2);
 userGr.update();

}

 


Please mark this correct & helpful if it answered your question.

 

Thanks & Regards,
Sharjeel

 

Regards,
Muhammad