indexOf not working as expected?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-26-2021 06:14 AM
How to compare the string with exact match?
myString = "networkgroup@abc.com";
"network@abc.com" also satifying this condtion
Is there a way to find the exact string insted of indexOF()
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-26-2021 06:18 AM
You should be able to find the exact string using something like this. This is in an IF statement in a run script in a workflow:
answer = ifScript();
function ifScript() {
if (workflow.scratchpad.outputdataUser.indexOf("CN=TEST_EMAIL_GROUP") > -1) {
return 'no';
}
return 'yes';
}
Just put exactly what you are looking for in the string.
If the string is just an email address and that's all that is in it each time, you could just use an IF statement then. indexOf() is typically used to find a string location within a larger string and if it returns a number greater than -1 then the string was found.
Please mark this response as correct and/or helpful if it assisted you with your question.
Steven
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-26-2021 06:19 AM
Hi,
in your current string if you try to find network@abc.com it should give you index as -1 as it won't find that
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-26-2021 06:24 AM
That's for example
Comment = 'EVM00238-to1' not found/n
mystring = EVM00238
if(Comment.indexOF(mystring)>-1)
this condition is satifying right now but I dont't want to do that, instead I want to match the exact string
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-26-2021 06:38 AM
I am not comparing eamil id for exaMPLE i HAVE shared that,
Comment = 'EVOOTBM-T05' is not exist;
myString = EVOOTBM;
if(Comment.toString.indexOF(myString)>1)
Now this should not satify but is is matching,
That's why I want a exact string matching condition