Inbound Action

purdue
Kilo Sage

Hello,

 

I need some assistance with an inbound action.   I need to populate the email address of the sender in the email variable and need to populate the email body in the description of the sc_task. 

Thanks,

Chad

 

createRequest();
function createRequest() {
var cartId = GlideGuid.generate(null);
var cart = new Cart(cartId);
var item = cart.addItem('70e9b1c01b2912d08d722f4b234bcb9a');
//var sid = email.body.request_generated_by.trim();
cart.setVariable(item,'requested_for', gs.getUserID());
cart.setVariable(item, 'short_description', email.subject.toString());
cart.setVariable(item, 'email',email.receipient.toString());
var rc = cart.placeOrder();
var tsk = new GlideRecord('sc_task');
tsk.addQuery('request', rc.sys_id);
tsk.query();
while (tsk.next()) {
tsk.description = email.body_text;
current.update();
}
1 ACCEPTED SOLUTION

Hello,

I was able to overcome this however I need to set condition to only return true if domain in sys_property matches user domain.   I tried this in condition but is not working.   Any idea?  

gs.getProperty('wbd_domains').toLowerCase().indexOf(email.origemail.split('@')[1].toLowerCase()) >=0

Thanks,

Chad

View solution in original post

7 REPLIES 7

Runjay Patel
Giga Sage

Hi @purdue ,

 

As per your code you are not creating any sc task then how you can update.

is sc task getting created by any other flow?

if not then first you need to create and while creating you set that value.

 

 

Hello,

From what I am remember Cart API creates the Catalog Task automatically thus no need to manually generate task.   I simply wanted to add email body to description.   I am going to try to add to RITM and see if BR copies to task.

Thanks,

Chad

Hi @purdue ,

 

sc_task will not generate by invoking cart.placeOrder(). It will only create REQ and RITM.

If sc_task is getting created for you then must be because of some other flow.

 

-------------------------------------------------------------------------

If you found my response helpful, please consider selecting "Accept as Solution" and marking it as "Helpful." This not only supports me but also benefits the community.


Regards
Runjay Patel - ServiceNow Solution Architect
YouTube: https://www.youtube.com/@RunjayP
LinkedIn: https://www.linkedin.com/in/runjay

-------------------------------------------------------------------------

In this video i have explained about Web service integration in ServiceNow like how it works, how we can configure it, what are the prerequisite and many more. I have covered below topics in this video. 1. understand Web Service. Like when and how we will use it. 2. Talked about Inbound and ...

Moin Kazi
Kilo Sage
Kilo Sage

Hi @purdue ,

 

Could you please share the complete requirement and specify where you have written the code you mentioned, as well as the purpose of using the Cart API in your code?

 

Here are a few helpful points:

  • To populate the email sender, you can use the "email.origemail" method.
  • To populate the email body, you can use "email.body_text".

 

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

If you found my response **helpful**, I’d appreciate it if you could take a moment to select **"Accept as Solution"** and **"Helpful"** Your support not only benefits me but also enriches the community.

 

Thank you!
Moin Kazi

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~