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

Copy Item variable to Request field

shane_davis
Tera Expert

I have a workflow on the sc_req_item table and the workflow has a script activity.   In the script activity, I am trying to copy the value of the "short description" variable to the short description field of the parent Request.  

I tried this with no luck.

sc_request.short_description = current.variables.short_description;

All help is appreciated!

1 ACCEPTED SOLUTION

Shane. My bad


Here is the updated script.



  1. //This function will be automatically called when this rule is processed.  
  2. var gr = new GlideRecord('sc_request');  
  3. gr.addQuery('sys_id',current.request);  
  4. gr.query();  
  5. while(gr.next())  
  6.   {  
  7.   gr.short_description = "Is this working?!"; //assuming short_description is the varaible part of catalog item  
  8.   gr.update();  
  9. }


There was error on 2nd line. Try now pls.


View solution in original post

7 REPLIES 7

Shane. My bad


Here is the updated script.



  1. //This function will be automatically called when this rule is processed.  
  2. var gr = new GlideRecord('sc_request');  
  3. gr.addQuery('sys_id',current.request);  
  4. gr.query();  
  5. while(gr.next())  
  6.   {  
  7.   gr.short_description = "Is this working?!"; //assuming short_description is the varaible part of catalog item  
  8.   gr.update();  
  9. }


There was error on 2nd line. Try now pls.


Pradeep,



        You are amazing!!   I tested hard-coding per your last update and that worked.   Then, I put the code for the short description variable back in and that worked also.



        I've seen many responses from you on the Community and you are a great help.   When I see code like this, I understand it, but writing it from scratch is such a challenge!   Thank you very much for your help.   I really appreciate it and will make your answer as correct.



//This function will be automatically called when this rule is processed.


var gr = new GlideRecord('sc_request');


gr.addQuery('sys_id',current.request);


gr.query();


while(gr.next())


  {


  gr.short_description = current.variables.short_description; //assuming short_description is the varaible part of catalog item


  gr.update();


}


Hi Shane,



Thanks a lot for your feedback


I am glad I can be helpful to you.