inbound action

Jack62
Giga Guru

Evening all,

I am working on an inbound action which is behaving rather odd. it is meant to fire a specific cat item, log as the person emailing in and take the subject and body as short description and description. At the moment the inbound action states it is being skipped but a the request again the ritm is being generated, logging as the person sending in the email, the short description is not mapping but description IS the body of the email

 

Any thoughts on why the inbound action is stating it skipped when it logged? the error on the email logs is 

create cat request : did not create or update sc_request using current

 

My inbound action script is below

 

 

createRequest();

function createRequest() {

var cart = new Cart(); //calling the cart API

var item = cart.addItem('4c1398342f302010f2aee36ef699b6f5'); //sys_id of the catalog item I want to fire

cart.setVariable(item, 'subject', email.subject); //sets catalog variable to the email's subject

cart.setVariable(item, 'emailbody', email.body_html); //sets catalog variable to email's body

var rc = cart.placeOrder(); //this launches the catalog item, and creates a request object. rc = the request object

updateRITM(rc.sys_id); //call a function immediately to update the ritm. This must be a nested function, otherwise inbound actions get weird.

//also, we're passing the sys_id of the request so we know what RITM to grab.

}

function updateRITM(req){

var ritm = new GlideRecord('sc_req_item');

ritm.addQuery('request', req); //req is what we passed from the previous function. the sys_id of the request.

ritm.query();

while (ritm.next()){

ritm.u_customer = gs.getUserID(); //my ritm table separately tracks its own customer, since I don't use Request

ritm.description = email.body_text; //we're still in the inbound action so why not exploit?

ritm.priority = email.body.priority; //good example of how to exploit email body variables

ritm.update();

}

}

event.state="stop_processing"; //stop evaluating inbound actions. This is why I keep this record's order lower than my incident from email rules.

1 ACCEPTED SOLUTION

Thanks for all the help Kieran

 

This is working end to end in my PDI. I have moved the update set in the proper dev instance and its no longer working. The  cat item and inbound action has come in, I have checked the sys ids that are in the inbound action script and checked all other conditions, the inbound email It gives me the same message against the UI Action as in my instance 

 

my-inbound - action - name : did not create or update sc_request using current

 

In the PDI instance it logs the req with the req_item but in dev it does nothing. 

 

Is there a setting, property etc that I need to look at? I have created the inbound action and cat item from scratch (And update the sys Ids) but still the same response

 

JAck

View solution in original post

15 REPLIES 15

Hi Jack,

Hard to say to be honest to why it's not working. I'd suggest adding some logging statements to ensure everything is working as expected.

The JSON object which is outputted should contain the Request values, that'll help assess whether the REQ is being correctly generated.

try{
		var cart = new sn_sc.CartJS();
		var item = {
			'sysparm_id': '1dc3e6912f3c20101c43bed72799b67d',
			'sysparm_quantity': '1',
			'variables': {
				'email_body': email.body_text
			}
		};

		var cartDetails = cart.orderNow(item);
		logger.log(JSON.stringify(cartDetails));
	} catch (e){
		logger.logWarning(e);
	}