Run script in workflow - copy "select box" variable to another "select box" variable

onthego
Giga Contributor

In a workflow, I'm trying to copy a requested item variable value from one requested item to current in a run script.   Both choice lists are identical, both variables are typed as "select box" with None.   The result I get looks to set the value but not the display value.   I've tried doing the setValue and setDisplayValue with no success.   Anybody encountered this?

The code looks like:

gr = new GlideRecord('sc_req_item');

if (gr.get(ritm)) {        

        current.variables.u_solution = gr.variables.u_solution;

}

Thanks in advance.

1 ACCEPTED SOLUTION

onthego
Giga Contributor

Thanks.   For this variable type, it didn't seem to do the complete job.   The display was seemingly set, but the value was not stored on the form.   I tried these possibilities below to introspect what was possible:



gs.log('WF==> gr.getDisplayValue->u_solution=' + gr.getDisplayValue('variables.u_solution'));


gs.log('WF==> gr.getValue->u_solution=' + gr.getValue('variables.u_solution'));


gs.log('WF==> gr.variables.u_solution=' + gr.variables.u_solution);



I got something intelligent back on the first and third methods.   The third method wound up working for me on this select box (as posed as the original problem). I guess I must have had a typo along the way.



Thanks again for your help.


View solution in original post

2 REPLIES 2

venkat2
Kilo Expert

Hi,



Try using the setDisplayValue with the below syntax. I experienced similar behavior and this syntax helped me in most situations.



gr.setDisplayValue('opened_at','2011-02-13 4:30:00');


onthego
Giga Contributor

Thanks.   For this variable type, it didn't seem to do the complete job.   The display was seemingly set, but the value was not stored on the form.   I tried these possibilities below to introspect what was possible:



gs.log('WF==> gr.getDisplayValue->u_solution=' + gr.getDisplayValue('variables.u_solution'));


gs.log('WF==> gr.getValue->u_solution=' + gr.getValue('variables.u_solution'));


gs.log('WF==> gr.variables.u_solution=' + gr.variables.u_solution);



I got something intelligent back on the first and third methods.   The third method wound up working for me on this select box (as posed as the original problem). I guess I must have had a typo along the way.



Thanks again for your help.