Generate a change request through Inbound email action

abhishekmittal
Tera Contributor

Hi,

We have an inbound email action which creates incident but whenever we have "xyz" in the subject line, we need to generate a change request instead of incident.

How can we achieve this please help me to find the solution?

Regards,

Abhishek

12 REPLIES 12

bernyalvarado
Mega Sage

Hi Abhishek,



You can do it through the Service Catalog API, using the Cart object.



Thanks,


Berny


Thanks Alvarado,



But I don't need to generate request item, I need to generate change request.


Please help me with code.



Regards,


Abhishek


Hehehe. lol. Sorry


Karthik Reddy T
Kilo Sage

Hello Abhishek,



Inbound action:


Create new> Type is reply



Table is Incident:


Condtion: Email subject contains: XYZ,




Use the Below sample script for to creating a change request(action of inbound action).





var changeRequest = ChangeRequest.newNormal();


changeRequest.setValue("short_description", current.short_description);


changeRequest.setValue("description", current.description);


changeRequest.setValue("cmdb_ci", current.cmdb_ci);


changeRequest.setValue("priority", current.priority);


changeRequest.setValue("sys_domain", current.sys_domain);


changeRequest.setValue("company", current.company);


changeRequest.insert();



current.rfc = changeRequest.getGlideRecord().getUniqueValue();


current.update();



gs.addInfoMessage("Change " + changeRequest.getValue("number") + " created");



Let me know you need any other information   related this.


Karthik Reddy T.
ServiceNow Commnunity MVP -2018 class.