- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-12-2025 12:20 AM
need to check the logged in user title exact matches the title which i declared in system property.
example;- created a system property with title like "FC Manager,Field Service Technician II,Manager, Field Service,MOT DC Manager,Senior Manager, Field Service,Sr Fabricator,Sr Field Service Technician,Sr Service Technician,Supervisor-Field Service" , suppose logged in user title is "SERVICE TECHNICIAN", it should not satisfy the condition, only satisfy the condition when logged in user title is "Field Service Technician II" or "Sr Service Technician".
Please help me out.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-12-2025 02:22 AM
then store that in a string variable, use split and it gives you array and then search in that array using indexOf.
But storing in property is recommended, considering in future if any title is added/removed then you need not change the script.
I believe I have provided enough guidance on your question.
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-12-2025 01:12 AM
if logged in user title is Field Service Technician then this title is present in Array so it will satisfy IF condition
what's your actual question?
If you only want to compare against these 2 Field Service Technician II" or "Sr Service Technician
then why to use system property?
Simply compare them in script itself.
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-12-2025 01:50 AM
Hello @Ankur Bawiskar ,
Actually i have 40 titles to check, so thats why i create a system properties.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-12-2025 01:55 AM
So what's your requirement.
Property has 40 titles and if logged in user title belongs to that property then it goes to IF
I didn't get what didn't work for you?
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-12-2025 02:01 AM
Hello @Ankur Bawiskar ,
Below is the titles:-
Automation Operations Manager,Branch Manager,Branch Sales Manager,Div Ops Support,Division Sales Center Manager,DivisionSupport,FC Warehouse Manager,Group Operations Support,On-Site Mgr,On-Site Senior Manager,On-Site Supv,Operations Manager,Sales Admin Supervisor,Sales Center Supervisor,Sales Center Supv,Service Shop Manager,
Shop Mgr./MI Process Pump,Shop Operations Manager,Shop Supv,DC Manager,DC Supv,DC Whse Manager,FC Manager,Field Service Technician II,Manager, Field Service,MOT DC Manager,Senior Manager, Field Service,Sr Fabricator,Sr Field Service Technician,Sr Service Technician,Supervisor-Field Service,Warehouse Mgr,Br.Mgr/Montreal FP Shop,Ops. Mgr. / FPH / Toronto,Ops.Mgr./Belleville,Ops.Mgr./Brandon,Ops.Mgr./Calgary,Ops.Mgr./Red Deer,Ops.Mgr/Quebec City,Shop Supervisor,Sr. Machinist.
Need to add logic in workflow if any logged in user title macthes the exact title present above case insensitive it should go to yes otherwise return no
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-12-2025 02:11 AM
then in system property store everything in lower case, get logged in user title and convert to lowercase and then compare exact match
But this will work only when the titles you store match exactly as per User record title, any extra space or dot will lead to script failure.
1) store this in system property
automation operations manager,branch manager,branch sales manager,div ops support,division sales center manager,divisionsupport,fc warehouse manager,group operations support,on-site mgr,on-site senior manager,on-site supv,operations manager,sales admin supervisor,sales center supervisor,sales center supv,service shop manager,shop mgr./mi process pump,shop operations manager,shop supv,dc manager,dc supv,dc whse manager,fc manager,field service technician ii,manager,field service,mot dc manager,senior manager,field service,sr fabricator,sr field service technician,sr service technician,supervisor-field service,warehouse mgr,br.mgr/montreal fp shop,ops. mgr. / fph / toronto,ops.mgr./belleville,ops.mgr./brandon,ops.mgr./calgary,ops.mgr./red deer,ops.mgr/quebec city,shop supervisor,sr. machinist
2) then use this in script
var titleArray = gs.getProperty('jobTitles');
gs.print("property title " + titleArray);
var loggedInUserTitle = gs.getUser().getTitle().toLowerCase();
gs.print(" title " + loggedInUserTitle);
if (titleArray.indexOf(loggedInUserTitle) > -1) {
// logged in user title is belonging to array
gs.print("yes");
} else {
gs.print("no");
// title not present
}
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader