Hi, I'm trying to call an expression through a query result, is there a

Hi,
I'm trying to call an expression through a query result, is there any way for it to be done? Like, say, calling an expression by it's uuid?

Thanks

OriginalPostID-217820

OriginalPostID-217820

  Discussion posts and replies are publicly visible

  • I know passing rule references to other rules as rule inputs. Consider the following rule which takes in a rule reference as input and executes it inside.

    Rule:
    executeMyRule(ruleToBeExecuted<AnyType>, dataToBePassed<AnyType>){
    apply(ri!ruleToBeExecuted, {ri!dataToBePassed})
    }

    And we can call this rule as follows...
    rule!executeMyRule(fn!dollar, "345")
    rule!executeMyRule(fn!dollar, {"123", "345"})

    This procedure can be used to create application level common rules where the rules to be executed/applied are not decided at design time but rather decided at run time. A most common use-case is to pass formatter rules to a SAIL component which applies the format passed in as a rule input.

    If you want to call an expression through a query result, can you see any possibility of getting rule references(rule!ruleName as string) from database/query and pass it to the above rule ?

    I might have misinterpreted your question but felt like worth sharing.
  • Above discussed way of invoking a rule has been present in Appian since long back in Appian Common Objects in a rule called APN_uiGridTextColumnAuto, and this has been mentioned at forum.appian.com/.../e-206210. In this rule we can see how Appian is trying to invoke a rule by making use of the rule input which again gets rule reference when invoked from other rules. I have tried long back passing the string as input to those rule inputs that has the capability to accept the rule references and I didn't find any luck. Attached images of the Editable Paginated Grid(which I have implemented as a Reusable Component) and they explain how the interface behaves when a string is passed to the rule input that expects rule reference. The problem here as per my knowledge is, the rule input that has the capability to accept a rule as input expects reference and when we send a string it fails to understand/obtain/derive the reference from the string and so the interface fails.

    Further I have observed few issues with the above discussed approach which were mentioned by me some time ago at forum.appian.com/.../e-169115. And the most important problem as far as my experience is considered is, the inputs part. As each rule will be having its own unique structure in terms of inputs, it becomes quite complex to analyse the structure of rule inputs and read their content especially when the rule inputs are of various complex data types and are in array format.


  • 0
    Certified Senior Developer
    Try using eval( ri!txt ) where ri!txt can be rule!abc_getSomethingFromDB("MyParameters").
  • Hi, sorry for the late response. eval(ri!txt) works like a charm. Thank you!
  • @erick258, that's cool !! Using eval() function, can you pass "rule!abc_getSomethingFromDB("MyParameters")" as a string or does it also expect the function to be passed as a function reference ? Can you please elaborate on how did you get this to work, so that it can be useful for others too ?