Interested in a ServiceNow event built for developers? Registration for now[dev]26 is officially open!

In virtual agent,based on user's home country the case creation for HR services should change

Nive G
Tera Contributor

In virtual agent, the case creation on HR services should change based on the logged in user's home country,is that possible? how?

 

Example: So if user is from India the HR service should be General Inquiry or if user from US the HR service should be Payroll

 

2 ACCEPTED SOLUTIONS

@Nive G 

you will require script for this

use the Script action and check which country logged in user belongs

Then use Decision and based on that use Record action

 

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 10x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

View solution in original post

@Nive G 

update as this

var gr = new GlideRecord('sn_hr_core_profile');

gr.addQuery('user',vaInputs.user.sys_id);

gr.query();

if(gr.next()) {

	var location = gr.country_of_birth.getDisplayValue();

	vaVars.location = location;
}

})()

then in decision use the exact country name to match in IF

if(vaVars.location=='United States of America'){
	return true;
}
else{
	return false;
}

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 10x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

View solution in original post

8 REPLIES 8

@Nive G 

you will require script for this

use the Script action and check which country logged in user belongs

Then use Decision and based on that use Record action

 

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 10x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

@Ankur Bawiskar 

 

var gr = new GlideRecord('sn_hr_core_profile');

gr.addQuery('sys_id',user);

gr.query();

if(gr.next()) {

var location = gr.country_of_birth;

vaVars.location = location; }

})()

 

This is the script action I have used but this is not taking me to the next decision flow

 

Nive G
Tera Contributor

@Ankur Bawiskar 

 

if(vaVars.location=='dd38b7111b121100763d91eebc0713f5'){
return true;
}
else{
return false;
}
 
This is the script given in decision branch flow.

@Nive G 

update as this

var gr = new GlideRecord('sn_hr_core_profile');

gr.addQuery('user',vaInputs.user.sys_id);

gr.query();

if(gr.next()) {

	var location = gr.country_of_birth.getDisplayValue();

	vaVars.location = location;
}

})()

then in decision use the exact country name to match in IF

if(vaVars.location=='United States of America'){
	return true;
}
else{
	return false;
}

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 10x ServiceNow MVP  ||  ✨ ServiceNow Community Leader