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.

Need help dot walking in assignment script for Assigned to.

taylor21
Mega Expert

Hi all,

I am attempting to create an assignment rule that sets the "Assigned to" field to the "Opened for's" Business Partner which is a value populated in their HR Profile. The Opened for field is a reference to the user table. I'm a beginner with scripting so I am looking for some assistance on how to populate the current record's "Assigned to" field with the Opened for's Business Partner using an Assignment rule or a Matching rule. Any assistance is greatly appreciated.

 

Taylor

16 REPLIES 16

Erik Stolberg
Tera Guru

Something like this would work. Replace the u_business_partner with whatever your custom field is named (since I don't see Business Partner field on my hr_profile table).

(function (){
	var profileGR = new GlideRecord('hr_profile');
	profileGR.addQuery('user', current.opened_by);
	profileGR.query();
	if (profileGR.next()) {
		current.assigned_to = profileGR.u_business_partner;
	}
})();

Archana Reddy2
Tera Guru

Hi Taylor, 

I have not worked on HR tables yet. Below one is the code of Erik and is edited.

Create a before BR on your current table. Check Insert and Update as required.

var profileGR = new GlideRecord('hr_profile'); profileGR.addQuery('user', current.opened_by); profileGR.query();

if (profileGR.next()) {

current.assigned_to = profileGR.u_business_partner; }

Hope this helps!

Thanks,

Archana

Ah forgot the "query" line... I've edited my code. Thanks for catching!

No mention Erik!