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
Hello jagjots3791
Not sure uf i completely understand your question. But from what I understand, you want to use a set of values even if the user/process doesn’t provide values to them.
you can have the values set in locals and use default value function.
If your question is about query filter or rule parameters you can handle it with the apply when or simple if logics.
Did you consider to use a list or a map?
What are you aiming for? Appian is not Java, trying add more levels of abstraction gets you quickly into unsafe waters.
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).
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] ) )
No, that is not possible. The best thing you can do (and honestly, I've found it to be sufficient in nearly 100% of my use cases over the past 11+ years) is to call all parameters and conditionally pass values to them.
Thank you. Thats what I wanted to know.
Cool, thanks for confirming