- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-30-2022 07:13 AM
Hi Team,
I need to copy catalog item variable field value [location] which is a reference field referring to custom table [u_one_team_workflow_location], to custom field [u_service_location_test] on RITM which is also reference field referring to same custom table.
I have tried all possible ways but unable to get the value on RITM field [u_service_location_test].
please refer the image
custom table:
custom field on RITM
Variable on cat item
Tried Solution
before BR on sc_req_item table on insert and update
Thanks
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-30-2022 10:00 AM
Hello,
I see maybe the name field is u_name in the backend. Then please use the below:-
(function executeRule(current, previous /*null when async*/) {
gs.log('location'+current.variables.location);
var ritm_gr = new GlideRecord('u_one_team_workflow_location');
ritm_gr.addQuery('u_name', current.variables.location);
ritm_gr.query();
if(ritm_gr.next())
{
current.u_service_location_test=ritm_gr.sys_id;
current.update();
}
})(current, previous);
Please mark my answer as correct based on Impact.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-30-2022 07:23 AM - edited ‎11-30-2022 07:24 AM
Hello,
Please change the BR to after insert/update on sc_req_item table and add current.update();
As I do not think the variables get attached to the RITM before insertion so the value will not come in the before BR
Please mark my answer as correct based on Impact.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-30-2022 08:59 AM
Yes, I tried it but did not work.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-30-2022 09:10 AM
I just noticed you are using a lookup select box with name. You need to use glide record to that one team workflow location table:-
Create an after insert/update on sc_req_item table with below code:-
(function executeRule(current, previous /*null when async*/) {
var ritm_gr = new GlideRecord('u_one_team_workflow_location');
ritm_gr.addQuery('name', current.variables.location);
ritm_gr.query();
if(ritm_gr.next())
{
current.u_service_location_test=ritm_gr.sys_id;
current.update();
}
})(current, previous);
Please mark my answer as correct based on Impact.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-30-2022 09:32 AM
The thing is whenever i give after BR inster/update and current .update the RITM itself not getting created.
and i tried the above code using Before BR , for every cat item created with diff location, on RITM field u_service_location_test its populating only single value 'Gilbert.
