Question
Nielsen
US
Last activity: 10 Jun 2016 11:31 EDT
Customize Error Messages
Hi - I need to validate an input text to check if the value is greater than another input property.
If yes , I need to display a custom error message containing both the property values ;
Example : Please enter a value between 20 and 25 . Where 20 and 25 are input by the user in the earlier steps.
Thanks,
Smitha
-
Like (0)
-
Share this page Facebook Twitter LinkedIn Email Copying... Copied!
Accepted Solution
Pegasystems Inc.
US
Hi Smitha,
Can the code be similar to the following?
String xValue = myClipboardPage.getString("xProperty");
if (theValue > xValue) {
theProperty.addMessage("Please enter a value less than "+xValue);
return false;
}
return true;
Thanks,
Susan
Pegasystems Inc.
US
Message rule
When an input value fails validation by an edit validate rule, the system adds the message rule named PropertyInfo-EditValidate to the property. The default text is
Invalid value specified for {1}.
where {1} identifies the property.
https://community.pega.com/support/support-articles/error-message-displayed-not-meaningful
https://docs-previous.pega.com/how-specify-error-message-text-within-java-code-edit-validate-rule
Thanks,
Susan
Nielsen
US
Thank you for the answer. The solution helps me customize messages but I need to use another property's value in the error Message.
As I understand the current property can be referenced by :
theValue —the String value of the property
But how can I refer to any other property in the same page ?
My error message needs to be :
Please enter a value less than X .
Here X refers to another property.
Thank you for your help.
-Smitha
Hi Smitha,
Would the following be of help:
Will this value (X) be in some clipboard page? If so, you can reference the property using the pagename.
-Shan
Nielsen
US
Hi Shan - Yes the value will be available in clipboard.
Can you help me with the syntax of referring to the clipboard page from either the Java code (in edit validate rule) or from the Error Message .
Thanks,
Smitha Rajasenan
Accepted Solution
Pegasystems Inc.
US
Hi Smitha,
Can the code be similar to the following?
String xValue = myClipboardPage.getString("xProperty");
if (theValue > xValue) {
theProperty.addMessage("Please enter a value less than "+xValue);
return false;
}
return true;
Thanks,
Susan
Nielsen
US
Thank you Susan.
This is very helpful , I am looking for a similar code.
However I get a compilation error when I use "myClipboardPage" , Am i missing any initialization here?
The error says :
Test compilation failed: ----------
1. ERROR in /Rule_Edit_Validate_samplevalidatenumber1_Validate_20160606T160539_624_GMT.java (at line 46)
String xValue = myClipboardPage.getString(".SampleClass.SampleVariable");
^^^^^^^^^^^^^^^
myClipboardPage cannot be resolved
Hi Smitha,
You would have to replace the 'myClipboardPage' with the actual clipboard page you have in your context which has the value of 'x'.
-Shan
Nielsen
US
Thank you Shan and Susan. I got it working .