Passing Expressions as Expression Parameters

Certified Lead Developer

Are there any plans to allow for the passing expressions as expression parameters? I think this would be an incredibly useful feature to add to the expression language.

  Discussion posts and replies are publicly visible

Parents Reply Children
  • 0
    Certified Lead Developer
    in reply to Colton Beck

    It could be the same thing. Can you provide me with the link to where this is described? Otherwise, if you can demonstrate the syntax that should suffice. Thanks!

  • You can take a look at the general expression documentation here.

    You can play around with this in the expression editor. For example, you can create a rule called rule!getDateByDateTime which takes in a datetime parameter. Instead of directly passing a datetime, you can pass another rule like rule!getDatetimeByDateAndTime, which will take date and time parameters.

     

    You can put these together like this: rule!getDateByDateTime(rule!getDatetimeByDateAndTime(ri!date, ri!time))

     

    Let me know if you have any other questions.

  • +1
    Certified Lead Developer
    in reply to Colton Beck

    Thank you. Yes, I am familiar with what you describe above. I am however referring to the passing of an expression rule as an argument ( rule input ) to another expression rule; not passing the result of an expression rule to another expression rule.

    I have experimented and I believe I have answered my own question. Here is an explanation if you're interested. It relates to the scenario of another thread we have been discussing ( https://community.appian.com/discussions/f/general/11194/accessing-cdt-field-properties ). So, I have a reusable interface expression that accepts AnyType of rule input where the inputs can be different CDTs. These CDTs do however have common field names, i.e. name, description. I want to pass a CDT specific validation ( expression rule ) as a rule into the interface expression that checks if the value entered for the name field already exists in the database, i.e. through the use of a!queryEntity. This would of course be different for each CDT. So, for example, I would have two expression rules named isCustomerNameUnique(name) and isProductNameUnique(name). Each of them would check if the name is unique and then return either null if it unique or a validation message indicating the the name is not unique, i.e. "The customer name already exists." or "The product name already exists.". The interface expression would then accept a rule input of AnyType called validation as well as a rule input of AnyType called entity. I could then invoke that expression when I need to validate user input. For example:

    a!textField(
      label: "Name",
      value: ri!entity.name,
      saveInto: ri!entity.name,
      validations: ri!validation(ri!entity.name)
    )

    Works! Thanks for getting me to think through this carefully! The answer came to me when I explored the concepts detailed here : https://docs.appian.com/suite/help/17.3/Expressions.html#passing-functions-rules-and-data-types-as-arguments

    What do you think?