Populating a Variable on sc_req_item table on update of catalog variable
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-21-2016 07:46 AM
I have a need to be able to populate a variable located on the request item table (u_tra_amnt) when a catalog variable (tra_amnt_given) is updated from the task level. I know I need a business rule and I have been able to run a couple and successfully populate that variable on submit, but if any changes are made to that variable, it doesn't update. I am using after update functionality, but it's not working.
The script I am using is current.u_tra_amnt = current.variables.tra_amnt_given;
That's a BR on the sc_req_table
Any thoughts??
Thank you all in advance!
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-21-2016 09:14 AM
Can you post the script you're using? You'll need to set all 3 variables to correct values.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-21-2016 09:18 AM
var sys_id = current.sys_id
var item_name = 'tra_amnt_given'
var item_value = 23;
var gr = new GlideRecord('sc_item_option_mtom');
gr.addQuery('request_item',sys_id);
gr.addQuery('sc_item_option.item_option_new.name',item_name);
gr.addQuery('sc_item_option.value',item_value);
gr.query();
gs.info(gr.getRowCount());
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-21-2016 09:23 AM
You need to replace current.sys_id with the sys_id of the test record from sc_req_item - do you know how to get that? "current.sys_id" works in your BR, but not in Background Script.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-21-2016 09:27 AM
Ah gotchya. Now with this:
var sys_id = '9391db4a0fb3a680ac50305be1050e9f';
var item_name = 'tra_amnt_given';
var item_value = '23';
var gr = new GlideRecord('sc_item_option_mtom');
gr.addQuery('request_item',sys_id);
gr.addQuery('sc_item_option.item_option_new.name',item_name);
gr.addQuery('sc_item_option.value',item_value);
gr.query();
gs.info(gr.getRowCount());
it is returning: *** Script: 0
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-21-2016 09:29 AM
wait wait wait! I put the wrong number in - I was reading a different field! I got it to return 1, which is correct.