User criteria Script
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-15-2024 11:37 PM
Hi Team ,
How can we show error message when user criteria returns false?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-16-2024 07:05 AM
@Souvik Since user criteria is a server side script, you can use gs.addErrorMessage() or gs.addInfoMessage() to show error or info message to your user.
gs.addInfoMessage('start must be before end');
Hope this helps.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-16-2024 07:17 AM
Hi @Souvik
To show an error message when a user criteria returns false, you typically need to handle this in a place where user actions or data validations occur. This can be done using a few different methods, such as within a Business Rule, Client Script, or UI Policy.
Business rule
(function executeRule(current, previous /*null when async*/) {
// Define your user criteria logic here
if (/* user criteria returns false */) {
gs.addErrorMessage('Your custom error message here.');
current.setAbortAction(true); // Prevents the record from being saved
}
})(current, previous);
Client script
function onSubmit() {
// Define your user criteria logic here
if (/* user criteria returns false */) {
g_form.addErrorMessage('Your custom error message here.');
return false; // Prevents form submission
}
return true; // Allows form submission
}
UI Action
function onClick() {
// Define your user criteria logic here
if (/* user criteria returns false */) {
gs.addErrorMessage('Your custom error message here.');
// Optionally: Redirect or abort action
return false; // Prevents further action
}
// Continue with UI action logic
}
I hope my answer helps you to resolve your issue, if yes please mark my answer helpful and correct.
thank you
rajesh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-16-2024 07:29 AM
Hi,
How do you envision this working?
If the user criteria returns false the user will not see the object itself. So where and how do you want to show the message?
Also, There will be a lot of catalogs/articles user cannot see, How and Why would you show message that article X exists but you cant see it for ABC reason. It will create more confusion?