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
  • 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).

  • 0
    Certified Senior Developer
    in reply to Mike Schmitt

    Yeah, I want to pass parameters like below in the rule thats not hardcoded and it should give what I written in expression original question. I guess its not possible.

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

Reply Children