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

Hi,

like this

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

new sn_hr_core.hr_ServicesUtil(current, gs).createCaseFromProducer(producer, cat_item.sys_id);

Regards
Ankur

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

Hmm that still didn't work. I want the actual user that populates in the employee_details_position_manager box to be the Opened For. of the case But the variable is just a text field so maybe that's why it's not working?

 

find_real_file.png

Hi,

I thought it's a reference and would work directly

so since it's text what will user enter there?

if user is entering email then query and get the sysId and store in opened_for

Regards
Ankur

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

Hi, 

It's not a reference field. The user submitting the service will be choosing an employee/position and then their manager populates based on the employee that was chosen. I want the opened for to be whoever populates in that field. 

Is this even possible if it isn't a reference field?

Thanks, 

Rylie 

Hi @Ankur Bawiskar ,

 

we have same requirement but the there not specific for any  groups - it should triggers to for all users to there respective managers.

1. subject person should be user 

2. opened for should be the manager

 

we have write the one line script in record producer:-

 

anandsunny_0-1670585548756.png

 

 can you please help me .

 

Thanks