Alternatives to hidden functions (eval() and sort())

Certified Associate Developer

Does anyone have alternatives (internal or plugin) to the internal functions eval() and sort()?

It has been indicated in previous posts that these functions are hidden functions and are not for general use.  We wish to avoid using these as they could be modified or removed at any point for future versions.

  Discussion posts and replies are publicly visible

Parents
  • If you have a limited number of functions that you're using inside eval(), then an option would be to create an expression rule that chooses between them. The rule would take in two inputs, a string to indicate which function to choose, and a dictionary of inputs to pass into the function. This is what the rule could look like:

    choose(
    wherecontains(ri!function, {"sum", "floor", "concat"}),
    sum(ri!inputs),
    floor(number: index(ri!inputs, "number", {}), significance: index(ri!inputs, "significance", {})),
    concat(ri!inputs)
    )

    Then you would call
    rule!evaluate(function: "floor", inputs: {number: 15.5, significance: 1})

Reply
  • If you have a limited number of functions that you're using inside eval(), then an option would be to create an expression rule that chooses between them. The rule would take in two inputs, a string to indicate which function to choose, and a dictionary of inputs to pass into the function. This is what the rule could look like:

    choose(
    wherecontains(ri!function, {"sum", "floor", "concat"}),
    sum(ri!inputs),
    floor(number: index(ri!inputs, "number", {}), significance: index(ri!inputs, "significance", {})),
    concat(ri!inputs)
    )

    Then you would call
    rule!evaluate(function: "floor", inputs: {number: 15.5, significance: 1})

Children
No Data