Passing dynamical no of parameters to a rule

Certified Senior Developer

Hi, I have a below rule with pre-passed 3 parameters. Now, Is there any way that I can store these parameters (para1, para2, para3) and its values (val1, val2, val3) in variables and pass them to the rule dynamically? The no of parameter will be changed as they could come from rule input or local variable.

Example: [Code] I have two variables local!para and local!val and end result is whats written in the expression is what I want. See, rule can accept 5 parameters but I have given only 2 in this case.

a!localVariables(
  local!para: {"para1", "para2"},
  local!val: {"val1", "val2"},
  rule!JS_abcRule(
    para1: "val1",
    para2: "val2"
  )
)

  Discussion posts and replies are publicly visible

Parents
  • 0
    Certified Lead Developer

    When you call a rule with Keyword Syntax (like you've done in your example), all parameters are optional as long as you've set up the rule to handle nulls.  From the calling rule or interface, you can invoke any subset (between 1 and all) of the parameters (it can't be zero unless the rule has none), and each one you utilize can conditionally be passed a value or not, depending on the logic you prefer.

    There's not really any additional way to "dynamically pass parameters", if i'm even reading your question right, because in any one invocation of the rule, any parameters you pass in must be hardcoded into the rule call (but this is where you can fall back on conditionally passing in a value for individual items if you wish).

Reply
  • 0
    Certified Lead Developer

    When you call a rule with Keyword Syntax (like you've done in your example), all parameters are optional as long as you've set up the rule to handle nulls.  From the calling rule or interface, you can invoke any subset (between 1 and all) of the parameters (it can't be zero unless the rule has none), and each one you utilize can conditionally be passed a value or not, depending on the logic you prefer.

    There's not really any additional way to "dynamically pass parameters", if i'm even reading your question right, because in any one invocation of the rule, any parameters you pass in must be hardcoded into the rule call (but this is where you can fall back on conditionally passing in a value for individual items if you wish).

Children