The Zurich release has arrived! Interested in new features and functionalities? Click here for more

Populating a Variable on sc_req_item table on update of catalog variable

alexcharleswort
Tera Expert

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!

17 REPLIES 17

Can you post the script you're using? You'll need to set all 3 variables to correct values.


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());


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.


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


wait wait wait! I put the wrong number in - I was reading a different field! I got it to return 1, which is correct.