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

Perfect, thank you Sharjeel

I need to do the same thing but in a catalog client script. following your logic i tried : 

            var supplierGR = prlGR.supplier_product.getRefRecord(); //cant use current in catalog client script
            var categoria3=supplierGR.getValue('product_category');
             g_form.setValue('u_categoria_3_livello', categoria3);