How do I set a catalog Variable value with an inbound email script action?

Mark_Bailey
Mega Guru

I need to set catalog variable when an inbound email action occurs. I've tried various scripting syntax and failed each time. Im trying to set a check box on the catalog item already submitted to True when this script processes.  

Type: CheckBox

Question: Department created on PS

Name: Department_created_PS

Cat Item: General Accounting New Department

____________________________________________________________________________

When the inbound action is triggered here is the script after trying many versions.

  1. gs.include('validators');

if (current.getTableName() == "sc_req_item") {        

                            current.work_notes = "reply from: " + email.origemail + "\n\n" + email.body_text;

                            current.u_Department_created_PS = "true";  

current.update();

  1. event.state="stop_processing";

}

1 ACCEPTED SOLUTION

Mark,



Can you try this line:



current.variables.Department_created_PS = true;


View solution in original post

7 REPLIES 7

While commented out "//" listed below are 7 different versions i have tried. I'm just guess at this point. It must be something related to how to call   a catalog variable.


I've set fields on inbound actions often but never on a catalog variable.  




gs.include('validators');


if (current.getTableName() == "sc_req_item") {


  current.work_notes = "reply from: " + email.origemail + "\n\n" + email.body_text;


  //current.variables.Department_created_PS = true;


  //current.variables.Department_created_PS = "true";


  //current.item_option_new_Department_created_PS = "true";


  //current.item_option_new_Department_created_PS = true;


  //current.variables.Department_created_PS = true;


  //current.variables.u_department_created_ps = true;


  //current.variables.department_created_ps = true;


  current.update();


  event.state="stop_processing";


  }


to update a catalog variable it's just like you typed above. current.variables.FIELDNAME = true; and then a current.update();


What I wonder here is if you get the correct record... how about you do a gs.log("HERE IS THE NUMBER " + current.number); before the IF-statement and then look at the logs to see what number you get there.. just to see that you atleast get the correct object.



Just to prove my point, you can easy try in a script background to see how to do it:




var gr = new GlideRecord('sc_req_item');


gr.get('d05e6cad0fed1a404cf365ba32050e2d'); //This sys_id is from a RITM i just took to test




gs.log(gr.number);


gs.log(gr.variables.powerpoint); //The RITM got a variable named powerpoint which is true atm. Logging showing the correct value.


gr.variables.powerpoint = false; //Now I set the value to false.


gr.update();



And if I now refresh the RITM I can see that the value has changed to false.



Let me know if you need any more help.



//Göran


Well I feel pretty stupid. All along through all of my script changes I was using the reprocess email function and my changes never worked. I decided to enter a brand new request and viola, it works fine.



I did not realize I could not use the reprocess email function in the email logs.



I'm sorry for the trouble guys.