Question
Virtusa
IN
Last activity: 4 Oct 2018 11:08 EDT
how to call message rule from edit validate
Can you please let me know how can we reference a message rule from a edit validate to display the error message on screen.
In the below example, i wish to use Message Rule instead of adding hard coded message.
if(b4 == true)
return true;
else
{
theProperty.addMessage("Invalid Phone");
return false;
}
**Moderation Team has archived post**
This post has been archived for educational purposes. Contents and links will no longer be updated. If you have the same/similar question, please write a new post.
-
Like (0)
-
Share this page Facebook Twitter LinkedIn Email Copying... Copied!
Accepted Solution
Virtusa
IN
Hi Govardhan ,
Before looking to your reply, i tried that only and came here to reply on Ashish message that creating the Message Rule in base class solved the issue.
Thank You Ashish and Govardhan.
But i am not sure why it is not working when the rule is in my class.
JPMC
IN
Hi Nitesh,
This is a public API which also accept the message rule.
theProperty.addMessage("RuleMessageKey\tText1\tText2...");
where RuleMessageKey is a key to a Rule-Message rule, and the optional
Text1, Text2 and so on are text values — separated by a backslash and literal
t character — that supply values for the numbered parameters {1}, {2},... in the message rule text
-
Xavier SANQUER
Virtusa
IN
Hi Ashish
I have a Message rule named as "ValidPhone"
adding the same in the addMessage within quote displays **ValidPhone itself on screen.
I used like this
theProperty.addMessage("ValidPhone");
Please correct if i missed anything.
JPMC
IN
What is your PRPC version?
also provide us the screenshot of your message rule called ValidPhone
Virtusa
IN
PRPC 7.1.8 CPM 7.1.3
I tried following method from where i can understand, just referencing the edit validate rule wont work. There must be some other referencing also.
In edit validate rule, i added,
theProperty.addMessage("InvalidDateValue"); ---- where InvalidDateValue is pega provided Message rule. Modified the message rule and set as "Invalid Postcode" in the rule.
Error Message is displayed as "Invalid Postcode"
theProperty.addMessage("InvalidPostcode"); --- where InvalidPostcode is the message rule i created. Here also i set message as "Invalid Postcode"
Error Message is displayed as "**InvalidPostcode"
JPMC
IN
Hi Nitesh,
I just wrote a sample activity where i do property validate and call an edit validate and also define theerror message as follows. Note i donot give message in my edit validate rule, but just return false.
i get the error message as expected.
Note in the generated java of teh activity it is using same API for addmessage.
...
if (okay_to_validate_1) {
editValidateStatus_1 = tools
.editValidate(pz_2, "IsInteger");
if (editValidateStatus_1 == false) {
pz_2.addMessage("IntegerValueBadFormat");
Hi Nitesh,
I just wrote a sample activity where i do property validate and call an edit validate and also define theerror message as follows. Note i donot give message in my edit validate rule, but just return false.
i get the error message as expected.
Note in the generated java of teh activity it is using same API for addmessage.
...
if (okay_to_validate_1) {
editValidateStatus_1 = tools
.editValidate(pz_2, "IsInteger");
if (editValidateStatus_1 == false) {
pz_2.addMessage("IntegerValueBadFormat");
}
}
Virtusa
IN
Validating the property in activity or validation rule on submit of flow action is different scenario. There are numerous way to do that and customized.
But i am more interested in just using a Edit Validate rule, Message Rule, and a property. I will add this edit validate rule in the property which in turns calls the Message rule to display error.
If we are using any Message Rule that Pega have provided, it works like a charm. But if we create a new message rule and use the same, issue arrises.
I guess Pega is storing all the Pega Provided message rule name somewhere to fetch and display.
Ashish Agrawal : Method you provided has 2 concern which does not satisfy my requirement
1. Use of Method Property-Validate. It requires activity to call this method.
2. Use of Pega provided message rule.
JPMC
IN
Hi Nitesh,
I just created a custom message rule and even then it works for me. Regarding uisng activity, that's just one thing i did but i checked the generated jav code and it uses same API so, you shd be good with that.
Ideally OOB emssage rule or custom one would work exactly same.
However if you are facing the issue, i would request you to send the exact code of your edit validate rule and i will try the same in my local.
Nitesh, what's the AppliesTo class of your message rule? If it's your class, try moving message rule to @baseclass and test it to see if it displays the message..
Accepted Solution
Virtusa
IN
Hi Govardhan ,
Before looking to your reply, i tried that only and came here to reply on Ashish message that creating the Message Rule in base class solved the issue.
Thank You Ashish and Govardhan.
But i am not sure why it is not working when the rule is in my class.
This is an issue thats there for ages with message rules and correspondence rules
Pegasystems
US
The issue of only out-of-box errors showing up rather than your customer errors might be alleviated by turning off client-side-validation. Please see SA-12265 .
/Eric
Amazon
IN
The message rule must be in the same class as the property to display the correct message.
AI4Process Ltd
GB
boolean retval=false;
if ((theValue!= null) && (theValue.length() > 0))
{
java.util.regex.Pattern p =
java.util.regex.Pattern.compile("[0-9]");
java.util.regex.Matcher m= p.matcher(theValue);
retval = m.find();
if(retval)
theProperty.addMessage("DigitNotAllowed");
}
return true;
I am not able get message in UI,configured in DigitNotAllowed message rule when I am calling Edit-Validate rule from property.Can anyone please suggest the issue.