Help with a record producer script- changing Opened For person

Rylie Markle
Tera Contributor

I am hoping to write a script on a record producer that changes who the "Opened For" user is based on what group the "Opened By" user is in. 

I currently have it set up so that the Opened For person is always the Subject Person's manager (script below). However, I need it changed so that this only occurs when the Opened By is a member of a certain HR Group (Employee Relations). Is it possible to do this right on the record producer script? 

I was thinking something like this:

var isER = (gs.getUser().isMemberOf("f65370019f22120047a2d126c42e705c"))
if (isER) {
return current.opened_for = producer.subject_person.manager; }

 

find_real_file.png

1 ACCEPTED SOLUTION

Ankur Bawiskar
Tera Patron
Tera Patron

Hi,

update as this

if(gs.getUser().isMemberOf("f65370019f22120047a2d126c42e705c")) {
	current.opened_for = producer.subject_person.manager;
}

Regards
Ankur

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

View solution in original post

10 REPLIES 10

Ankur Bawiskar
Tera Patron
Tera Patron

Hi,

add this line as 1st line and then use the OOB line

if(gs.getUser().isMemberOf("f65370019f22120047a2d126c42e705c")) {
	current.opened_for = producer.subject_person.manager;
}

Regards
Ankur

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