populate reference field value in workflow Approver user action in servicenow

Rini1
Tera Guru

Hi all,

I am trying to populate approvers from a reference field from WRP form through workflow approval user action. We have a reference field 'Business service' on the WRP form. Once the request is logged by the customer, this field will be filled in internally from backend. I have included an approval action in the workflow to populate the 'Business service owners' based on the Business service selected. Below is the script, any guidance would be much appreciated.

PS: Iam not sure if this line is causing the problem 'var bsowner = current.variables.u_business_services;'. When I checked the log it says 'Undefined'

answer = [];
var bsowner = current.variables.u_business_services;
var gr = new GlideRecord('cmdb_ci_service');
gr.addQuery('name', bsowner);
gr.query();
while(gr.next()) {
answer.push(gr.getValue('u_serviceowner_2'));
answer.push(gr.getValue('u_seniorserviceowner_4'));
}

 

Thanks

Rini

1 ACCEPTED SOLUTION

A Record Producer only creates a record on the target table, not an RITM, so the workflow must be running on the table of the created record, not sc_req_item.  If you have a field on the target table named 'u_business_services' then the approval script would be:

answer = [];
answer.push(current.u_business_services.u_serviceowner_2.toString());
answer.push(current.u_business_services.u_seniorserviceowner_4.toString());

 

View solution in original post

6 REPLIES 6

A Record Producer only creates a record on the target table, not an RITM, so the workflow must be running on the table of the created record, not sc_req_item.  If you have a field on the target table named 'u_business_services' then the approval script would be:

answer = [];
answer.push(current.u_business_services.u_serviceowner_2.toString());
answer.push(current.u_business_services.u_seniorserviceowner_4.toString());

 

It worked! Thank you so much.