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

manikorada
ServiceNow Employee
ServiceNow Employee

Mark,



If its a Catalog Variable, you need to do something like:



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


event.state="stop_processing";


}


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


event.state="stop_processing";



I changed to this, and it processes but does not check the box as true.


Mark,



Can you try this line:



current.variables.Department_created_PS = true;


No luck.  


I don't think gs.include would have anything to do with the failure, but I have to keep that in for the inbound action to process.





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


  event.state="stop_processing";


  }