- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-09-2025 04:26 AM
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
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-10-2025 05:06 AM
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());
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-09-2025 06:06 AM
If you're not getting the expected value in the log, then that's the first place to start. Confirm that 'u_business_services' is exactly (case-sensitive) the name of a variable in the Catalog Item that this workflow is running on. If this is a reference variable, a sys_id will be seen in the log once the variable name has been corrected. If it is a reference to the cmdb_ci_service table, then you don't need a GlideRecord since this is a server script you can dot-walk, so your Approval - User script can just be something like this:
answer = [];
answer.push(current.variables.u_business_service.u_serviceowner_2.toString());
answer.push(current.variables.u_business_service.u_seniorserviceowner_4.toString());
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-09-2025 06:45 AM
No the 'Business service' field is not available on the catalog item. This field actually exist on the WRP form, so thats why I have used GlideRecord.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-09-2025 09:38 AM
If the workflow is running on the RITM that was generated from the Catalog Item, then 'current' refers to the RITM record, current.variables. gives you access to Catalog Item variables. If you don't have a reference variable on the Catalog Item for the Business service, how is the RITM related to the Business service? That is the variable or field that you need to assign to your bsowner script variable.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-09-2025 02:52 PM
Sorry if I am wrong. Its a record producer, but as you said the Business service' field is not available on the catalog item. It was configured directly on the WRP form (record producer - backend). Attached a screenshot for reference and only fields that are displayed under 'Customer provided information' comes from catalog item.
The Business service is the newly created reference field. Is there any other way where I can populate the Service owners based on the Business service selected (backend) on the form. Kindly get back if the query is unclear.