How to stop duplicate names being entered even with excess whitespace
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
5 hours ago
I'm working on a catalogue item and we've got a requirement where a user can't input the same name as an existing entry in the business application (cmdb_ci_business_app) table:
However, what we've noticed is that if the existing Business Application's name has whitespace before the current name itself, it doesn't produce an error message when a user enters the same name and doesn't clear the new name field:
The script include function that I'm using is:
I was just wondering if somebody has come across this issue before and what I can do to fix it.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
5 hours ago
if your record in "cmdb_ci_business_app" table has space before the name then it's a data issue, please fix that
With this space in prefix did you try to use encodedQuery() with LIKE operator i.e. use contains
gaBusinessApplicationName.addEncodedQuery(fieldName + 'LIKE' + fieldValue);
💡 If my response helped, please mark it as correct ✅ and close the thread 🔒— this helps future readers find the solution faster! 🙏
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
4 hours ago - last edited 4 hours ago
Thanks @Ankur Bawiskar . That works for white spaces, but if a user has a business application with a name of '301 Redirect Service' and they want to change it to '301 Redirect', that should be allowed, but the new addEncodedQuery will stop the user from doing that.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 hours ago
so you are saying if already name "301 Redirect Service" exists and if user enters 301 Redirect then it will throw error.
Yes it will throw error as it will use contains and find that text
I already informed in my 1st response having leading white space in your name field on your table is a data issue.
You need to fix that without which you can't make your requirement work
💡 If my response helped, please mark it as correct ✅ and close the thread 🔒— this helps future readers find the solution faster! 🙏
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader