Passing Parameters to Guardrail Message Rule

I’m trying to create a custom guardrail with a parameterized message. When I use the function @pxAddGuardrailMessageWrapper(“MyMessageRule”), the guardrail warning shows up correctly. However, when I try to add a parameter to the Message Rule, it doesn’t add the guardrail to the rule. I’m invoking it like @pxAddGuardrailMessageWrapper(“MyMessageRule\t123”). When I trace the scenario, I see a database call to get the message rule in the happy path, but no database transaction when I pass a parameter.

Any ideas as to things I could try to solve this?

Below is the rules I have configured.

@WesleyV3 please refer this article Add a custom guardrail warning | Support Center

Since the link above is broken, here’s what I had to do:

Created my own Rule-Utility-Function with the following code. Then, in my message rule, I used the parameters {1}, {2}, {3}, etc

//Guard Clause
if(MessageRuleWithParams == null) {
pega_rules_utilities.sendDebugMessageToTracer("AddGuardrailMessageWithParams | Return: MessageRuleWithParams == null " , “YourRSV”);
return;
}

//Split MessageRuleWithParams by tabs
String parts = MessageRuleWithParams.split(“\t”);
if (parts == null || parts.length == 0) {
pega_rules_utilities.sendDebugMessageToTracer(“AddGuardrailMessageWithParams | Return: No parts” , “YourRSV”);
return;
}

String MessageRule = parts[0];
HashStringMap parameters = new HashStringMap();

//Split the tab deliminated parameters into the HashMap
for(int i=1; i < parts.length; i++) {
parameters.putString(“”+i, parts[i]);
}

//Add Guardrail Message
com.pegarules.generated.pega_wb_default.pxAddGuardrailMessage(null, MessageRule, parameters);
pega_rules_utilities.sendDebugMessageToTracer("AddGuardrailMessageWithParams | Return: Successfully Added Guardrail “+MessageRule+”, " + parameters.toString() , “YourRSV”);