# Passing Parameters to Guardrail Message Rule

**URL:** <https://forums.pega.com/t/passing-parameters-to-guardrail-message-rule/10595>\
**Category:** General\
**Tags:** java-and-activities, 24-2-2, healthcare-and-life-sciences, pega-platform, lead-system-architect\
**Created:** [January 28, 2026, 11:56pm UTC](https://forums.pega.com/t/passing-parameters-to-guardrail-message-rule/10595 "2026-01-28T23:56:22Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![WesleyV3](https://avatars.discourse-cdn.com/v4/letter/w/a5b964/32.png) [@WesleyV3](https://forums.pega.com/u/WesleyV3)\
**Post date:** [January 28, 2026, 11:56pm UTC](https://forums.pega.com/t/passing-parameters-to-guardrail-message-rule/10595/1 "2026-01-28T23:56:22Z")

</div>

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.

 ![Message Rule.png](https://pega1.discourse-cdn.com/pega/original/3X/6/3/63a200ec14e6c450c268ccf3aed51361280ca5b1.png)

 ![Activity showing Code executed.png](https://pega1.discourse-cdn.com/pega/original/3X/b/a/baa4ce217f8faac232f6fe6b9eb9f3250e783247.png)

---

<div class="post-metadata">

**Author:** ![madaa](https://avatars.discourse-cdn.com/v4/letter/m/e9a140/32.png) [@madaa](https://forums.pega.com/u/madaa)\
**Post date:** [January 29, 2026, 6:29am UTC](https://forums.pega.com/t/passing-parameters-to-guardrail-message-rule/10595/2 "2026-01-29T06:29:14Z")

</div>

@WesleyV3 please refer this article [Add a custom guardrail warning | Support Center](https://support.pega.com/discussion/add-custom-guardrail-warning)

---

<div class="post-metadata">

**Author:** ![WesleyV3](https://avatars.discourse-cdn.com/v4/letter/w/a5b964/32.png) [@WesleyV3](https://forums.pega.com/u/WesleyV3)\
**Post date:** [May 27, 2026, 10:59am UTC](https://forums.pega.com/t/passing-parameters-to-guardrail-message-rule/10595/3 "2026-05-27T10:59:23Z")

</div>

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

 ![guardrailWithParamsFunction](https://pega1.discourse-cdn.com/pega/original/3X/6/7/6759e52670578805be2c2bd6e56c8e9236ddb151.png)

> //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”);
