- 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 09:35 AM
Hello,
Please check what value is coming in current.variables.location. Please use the below code and let me know what value is coming in location.
(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('name', current.variables.location);
ritm_gr.query();
if(ritm_gr.next())
{
current.u_service_location_test=ritm_gr.sys_id;
current.update();
}
})(current, previous);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-30-2022 09:53 AM - edited ‎11-30-2022 09:57 AM
on logs i am able to see the location i selected when i submitting the request but on RITM its still the same 'Gilbert'.
- 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 10:11 AM
Thanks a lot !!! it worked.
it worked when I tried above code using Before BR insert/update but when i did same using After BR Insert/update the RITM record itself not created.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-30-2022 09:46 AM
Hi @Bindhu1 ,
I would suggest to use Run script activity in workflow to update the location on sc_req_item table instead of using after BR. After BR with current.update() will affect the performance and not best practise to use it. So use current.u_service_location=current.variables.location in Run script activity of workflow.
Hope this helps!