Restrict list of words on single line text field on change validation
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-23-2023 02:30 PM
Hello,
We have a requirement to restrict few words and names on single line text field during on change .
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-23-2023 03:16 PM
Hi,
Try in your on change client script, mention the specific words and names declared in the array and then check those string in the newValue using indexOf method and validate it.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-23-2023 03:21 PM
Reading through your description, it sounds like you have a list of words that you want to prevent from being used in a text field.
One way to achieve this would be a Before Business Rule. This will allow you to validate the text before it is committed to the database, and you can then abort the update or remove the text. Here is some more information on Business Rules:
You would setup your business rule similar to below. You are going to put the field you are watching into the conditions (where I have Short description now). Make sure to have it run Before and on Insert and Update.
Then you can create a script in the Advanced section to check for your text.
I do not know your exact requirements, but if it is relatively easy to map out you could technically put the restricted words in the condition you see on the first tab and use the second tab to abort the action. I suspect there is a bit more you want to do (alert user of words, write a note, remove them and still allow the update) so the script is often easier. But if you have a straight forward set of actions, you might be able to do it through the interface.
You could do it on a client script but then someone could still update it via a list view. The business rule will intercept any updates to the record so I'd probably start there.
If you need any help refining this, just let me know. If you include some examples I can help code it up.