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,

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

I decided that I wanted the opened for to actually be the Position Manager instead of the subject person's manager. The Position Manager is a variable on the record producer (employee_details_position_manager). Is this possible? I tried the below script but it wasn't sucessful.

 

find_real_file.png

Hi,

add that if statement as 1st line and then add the line 1

Regards
Ankur

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

Is this what you meant? This didn't work, there was no one in the Opened For when I submitted the case. find_real_file.png