HR Case auto-assign based on incoming email using Inbound Action

Rob Sestito
Mega Sage

Hey SN Comm!

I am looking for some help with an inbound email action.

Aside from utilizing the Predictive AI Auto-assign feature in SN (I have a Case open with HI as there is an issue with ours), I want to build out an inbound action to start testing, in order to use those as an option for auto-assigning cases via emails.

My first try, I created an inbound action, using the HR Payroll table as the target. I took the same script from OOTB 'Create HR Case' Inbound Action. Only here, I changed the When to Run options. For the When to Run section, I stated for the condition: Subject contains paycheck/pay/paycheck issue.

At first, I had this Inbound Action NOT checked to Stop Processing. When I sent an email into the system, having my subject line read 'paycheck issue', the case was still created under General HR Service.

Then, I made it so the Stop Process box was checked. Sent email in. The Case was created under the right COE, assigned to the right assignment group, however still used the General HR Service.

Also, from the email logs, the Target field was empty, but I could see from the email logs related list area, that a Payroll case was created.

Is anyone able to assist me with created the proper inbound action, and how it should be created?

Here is what I have for reference:

find_real_file.png

find_real_file.png

//Set all basic HR fields
if (email.importance !== undefined) {
	if (email.importance.toLowerCase() == "high")
		current.priority = 1;
} else
current.priority = 3;

var bodyText = email.body_text;
if (!bodyText)
	bodyText = email.body_html;

current.work_notes = "HR Case created by email:\n\nReceived from: " + email.origemail + "\n\n" + email.subject + "\n\n" + bodyText;
current.description = bodyText;

// Core email rules assign "Guest" if the from email does not match a user.
// In this case, check the HR profile personal email, and reassing the case to that user.
var profile;
if (gs.getUserID() == '5136503cc611227c0183e96598c4f706') {        //GUEST SYS_ID
	profile = new GlideRecord('sn_hr_core_profile');
	profile.addQuery('personal_email', email.origemail);
	profile.query();
	if (profile.next()) {
		current.hr_profile = profile.sys_id;
		current.opened_for = '';
		current.opened_by = gs.getUserID();
		if (profile.user) {
			current.opened_for = profile.user;
			current.opened_by = profile.user;
		}
	} else {
		current.opened_by = gs.getUserID();
		current.opened_for = gs.getUserID();
	}
} else {
	// Find and attach profile if it exists
	current.opened_by = gs.getUserID();
	current.opened_for = gs.getUserID();
	profile = new GlideRecord('sn_hr_core_profile');
	profile.addQuery('user', gs.getUserID());
	profile.query();
	if (profile.next())
		current.hr_profile = profile.sys_id;
}

current.subject_person = current.opened_for;
var newId = current.sys_id;
gs.eventQueue('sn_hr_core_case.email.creation', current, newId, email.from);

 

Here is what I got after case was created (somewhat correctly)(with Stop Processing checked)

find_real_file.png

find_real_file.png

find_real_file.png

Had to go to list view of ALL cases (I think due to the wrong service still being used)

find_real_file.png

 

Any help would be great!

Cheers!

-Rob

 

1 ACCEPTED SOLUTION

Rob Sestito
Mega Sage

ServiceNow has found the error as to why our Predictive AI Auto-assign feature was not working.

We are moving forward with that, rather than deal with more Inbound Actions.

 

Thank you all!

-Rob

View solution in original post

9 REPLIES 9

maverik
Tera Contributor

Hi Rob,

There is one business rule "Set values on Topic fields" check this once also. It is running only on insert try to add update condition also.

I also faced issues on this part. Setting HR service via condition builder does not worked for me so I have added in the script. Please try that once.

And check any other inbound action should not be working if yes then you might need to add that negative conditions in inbound email action keywork is not payroll etc.

Thanks for the info maverik!

I will check this out!

-Rob

Rob Sestito
Mega Sage

ServiceNow has found the error as to why our Predictive AI Auto-assign feature was not working.

We are moving forward with that, rather than deal with more Inbound Actions.

 

Thank you all!

-Rob

Hi Rob,

We are facing similar issue with our inbound actions. Can you please let us know what was the error ServiceNow found with AI auto assign feature?

Roshani
Tera Expert

Hi Rob ,

I would like to setup predictive Intelligence for HR Case categorization . How should I proceed with this. Please let me know ?