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 run this and see what you get?



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



and



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


for the first one I get


*** Script: 93



and for the second one I get


*** Script: 1


So looks like you don't have the variable value of '23' for 'tra_amnt_given' in the sc_item_option table - can you confirm?



I also read purbali's comment and need to confirm what's triggering what change. Do you want



Changes to a variable value in sc_item_option will update a field value in sc_req_item



If so, you need to have this BR in sc_item_option as purbali said. Can you confirm?


No, I do. That's why I thought the script was throwing back a value of one.



And I think so?



What will happen is a user will input a request and one of the variables on the form (tra_amnt_given) will be left blank. Then a task will be assigned to Jane and while in that task, Jane will input a price in tra_amnt_given. After she has saved/closed the task, I want the value she put in that variable to populate a variable on the requested item table called u_tra_amnt.


Do you agree that the BR should be added to the sc_item_option table and when the value of the tra_amnt_given variable changes, the new value is written to the u_tra_amnt field in the sc_req_item table?



If so, you can still use the sc_item_option_mtom table to locate the record to update in the sc_req_item table you need to update.



Please let me know if this is the case and how I may help.