Inbound Email Action: did not create or update sn_customerservice_case using current

Nick69
Kilo Contributor

Hi All,

I can see this post has come up a bit in the past, but I can't work out my problem based on the previous solutions. Hoping someone can help me identify the issue 🙂 I didn't create this Inbound Action but am trying to work repair the fault.

Basically we have an inbound action to pick up ticket emails from other customer ServiceNow instances that we deal with (we are an MSP) and then create a case. The action will look for and store the ticket number from the other instance so we can reference it in another inbound action then add subsequent emails to the same ticket.

Cases have stopped being created (I believe this was working previously), and I can see the the Action is being run, but is returning "did not create or update sn_customerservice_case using current" - Please help!

(function runAction(/*GlideRecord*/ current, /*GlideRecord*/ event, /*EmailWrapper*/ email, /*ScopedEmailLogger*/ logger, /*EmailClassifier*/ classifier) {
	var reg = new SNC.Regex('/[A-Z]{2,}[0-9]{4,}/');
	var caseSub= email.subject;
	var caseNum = reg.match(caseSub).toString();
	var sender= email.from;
	var senderAcc;
	var senderId;
	var grAcc= new GlideRecord("customer_contact");
	grAcc.addQuery("email", sender);
	grAcc.query();
	if (grAcc.next()) {
       senderAcc=grAcc.account;
		senderId=grAcc.sys_id;
	}

	var grCase1= new GlideRecord('sn_customerservice_case');
	grCase1.addQuery('correlation_id',caseNum);
	grCase1.query();
	if(grCase1.next()){
		grCase1.work_notes=email.body_text;
		grCase1.update();
	}
	else{
		grCase1.newRecord();
		grCase1.correlation_id=caseNum;
		grCase1.short_description=caseSub;
		grCase1.description=email.body_text;
		grCase1.account=senderAcc;
		grCase1.contact=senderId;
		grCase1.category=15;
		grCase1.insert();

	}



})(current, event, email, logger, classifier);
4 REPLIES 4

Rajesh Chopade
Kilo Expert

Hi Nick, 

if other options not working for you then try this :

1) You can check - other Inbound email action is conflicting at run time or not


2) Check the 'Order' of Inbound email action, because lower 'Order' runs first.
that specifies when this inbound action runs relative to other inbound actions that use the same target table. The instance processes the action with the lowest order number first.


3) If other email action is running first due to order, then make sure 'Stop processing' check box should not be 'checked'.
Because this check box to prevent the system from running additional inbound email actions after this action runs.

 

Hoping this will help you, please mark my solution correct / helpful if it solved your problem.

 

Thanks,

Rajesh

Anil Lande
Kilo Patron

Hi,

You can put some info logs in your inbound action script to check what values are coming and at what point it is failing. Also use try catch to handle any run time exceptions.

I can suggest few logs like:

(function runAction(/*GlideRecord*/ current, /*GlideRecord*/ event, /*EmailWrapper*/ email, /*ScopedEmailLogger*/ logger, /*EmailClassifier*/ classifier) {
try{
gs.info('Inbound Case Running1 ');
	var reg = new SNC.Regex('/[A-Z]{2,}[0-9]{4,}/');
	var caseSub= email.subject;
	var caseNum = reg.match(caseSub).toString();
	var sender= email.from;
	var senderAcc;
	var senderId;
	var grAcc= new GlideRecord("customer_contact");
	grAcc.addQuery("email", sender);
	grAcc.query();
	if (grAcc.next()) {
       senderAcc=grAcc.account;
		senderId=grAcc.sys_id;
	}

	var grCase1= new GlideRecord('sn_customerservice_case');
	grCase1.addQuery('correlation_id',caseNum);
	grCase1.query();
	if(grCase1.next()){
gs.info('Inbound Case update Existing Case ');
		grCase1.work_notes=email.body_text;
		grCase1.update();
	}
	else{
gs.info('Inbound Case Create Case ');
		grCase1.newRecord();
		grCase1.correlation_id=caseNum;
		grCase1.short_description=caseSub;
		grCase1.description=email.body_text;
		grCase1.account=senderAcc;
		grCase1.contact=senderId;
		grCase1.category=15;
		grCase1.insert();

	}
}catch(e){
gs.info('Inbound Case Exception - '+e);
}


})(current, event, email, logger, classifier);

 

Thanks,

Anil Lande

Please appreciate the efforts of community contributors by marking appropriate response as correct answer and helpful, this may help other community users to follow correct solution in future.
Thanks
Anil Lande

Nick69
Kilo Contributor

Thanks for the suggestions guys, will check what you have both mentioned and report back.

Community Alums
Not applicable

Hi Nick,

 

Were you able to resolve this issue, i am facing the same with current object when trying to create case with Global scoped Inbound action. If you were able to resolve it, could you please share the resolution.

 

Regards,

Nitish Shaw