If there is a way to modify the workflow wherein if the user is brazil then the request assign BAG
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-02-2023 12:57 AM
Hi Community,
If there is a way to modify the Existing workflow wherein if the user is Brazil then the request should land to Brazil Assignment group
Please check this above screenshot and advise how can we modify the above workflow?
Regards,
Srinivasu
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-02-2023 02:23 AM
Sorry, but i need to auto assignment group in RITM not Catalog task,
if user is Brazil, will auto assign to Brazil assignment group in RITM
if user is not Brazil, will flow continue to other activates in workflow
Hope you can the requirement,
Could you please suggest workflow activities along with script that would be great full.
Thanking in advance
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-02-2023 02:33 AM
Hi @Srinivasu2
You can use same logic in Run script activity
/*1.Get the requested for*/
var reqFor = current.requested_for;
var country;
/*2.glide record on sys_user table*/
var grUser = new GlideRecord("sys_user");
grUser.addQuery("sys_id", reqFor);
grUser.query();
if (grUser.next()) {
country = grUser.location.country;
}
if(country == '<country_name here brazil>'){
current.assignment_group = <sys_id of brazil group>; //use system property to store sys_id. not to hardcode
/*Set scratchpad variable will be used in "If script" activity to diver flow*/
workflow.scratchpad.isBrazilUser = true;
} else {
current.assignment_group = <sys_id of another group>;
/*Set scratchpad variable will be used in "If script" activity to diver flow*/
workflow.scratchpad.isBrazilUser = false;
}
Use another "if" activity to divert the flow using scratchpad variable we set in above activity
answer = ifScript();
function ifScript() {
if (workflow.scratchpad.isBrazilUser == true) {
return 'yes';
}
return 'no';
}
Hope this helps..!!
ServiceNow Developer
I know one thing, and that is that I know nothing.
- Socrates
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-02-2023 04:33 AM
Yes, I have used your code but it will always assign to "else group" not assign to "brasil group".
I couldn't find where did i do mistake, Could you please check and help me
Regards,
Srinivasu
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-02-2023 05:17 AM
Hi @Srinivasu2
I can see there in user record you have country code field.
you can utilize that.
Check the backend value of choice Brazil from country code field & set it in run script
/*2.glide record on sys_user table*/
var grUser = new GlideRecord("sys_user");
grUser.addQuery("sys_id", reqFor);
grUser.query();
if (grUser.next()) {
//country = grUser.location.country;
country =grUser.<backend_value of country code field>
}
/*Check the backend value of Brazil from country code field*/
if(country == '<backend value of Brazil from country code field>'){
current.assignment_group = <sys_id of brazil group>; //use system property to store sys_id. not to hardcode
/*Set scratchpad variable will be used in "If script" activity to diver flow*/
workflow.scratchpad.isBrazilUser = true;
} else {
current.assignment_group = <sys_id of another group>;
/*Set scratchpad variable will be used in "If script" activity to diver flow*/
workflow.scratchpad.isBrazilUser = false;
}
OR
get the sys_id of Brazil location from location table & set it
/*2.glide record on sys_user table*/
var grUser = new GlideRecord("sys_user");
grUser.addQuery("sys_id", reqFor);
grUser.query();
if (grUser.next()) {
country = grUser.location;
//country =grUser.<backend_value of country code field>
}
/*Compare the sys_id*/
if(country == '<sys_idd of brazil location>'){
current.assignment_group = <sys_id of brazil group>; //use system property to store sys_id. not to hardcode
/*Set scratchpad variable will be used in "If script" activity to diver flow*/
workflow.scratchpad.isBrazilUser = true;
} else {
current.assignment_group = <sys_id of another group>;
/*Set scratchpad variable will be used in "If script" activity to diver flow*/
workflow.scratchpad.isBrazilUser = false;
}
ServiceNow Developer
I know one thing, and that is that I know nothing.
- Socrates