Hi Team,
I have a requirement to execute an expression rule by retrieving the rule name from the database. To provide a background on the ask: We have a landing page where tasks from various other applications/line of business is displayed. So every application designer would have to create an expression rule to return their tasks and then plugin to our common or parent expression rule. The parent rule consolidates all the tasks data from various applications and then display it in the grid. But the problem here is, one application might be in DEV phase, one in QA and another in UAT, so during the deployment there is always a problem due to the missing precedents and we have to comment out that rule that's not present in higher env and then uncomment it back. So in order to resolve this the business wanted to save all the rule names pertaining to each application in the DB and dynamically retrieve the rule name from DB and execute it.
I understand that we can pass the rule reference in the type "ANY", but in my case the rule name is saved as Text in DB.
Any ideas on this is appreciated.
Thanks
Discussion posts and replies are publicly visible
You can try to use the apply function. But I don't really recommend it.
If you want to avoid dependencies I think the best approach would be to have each app expose a Web API for the tasks and basically just call those APIs.
Thanks for the suggestion. One quick question though, how do you call an Web API from within Appian and how to handle authentications when the call is made from Appian
Not much different than if you were calling an external API.
You just expose a Web API and create an Connected System + Integration to consume it.
Maybe this can help:
Is there any way to execute an expression rule by its UUID/Name. The UUID/Name of the rules to be executed will be saved in the DB, during the runtime the system should read the UUID/Name and execute the rule corresponding to it.
You can get a rule name by its UUID via the "getContentDetailsByUUID" rule found in a particular plug-in (probably Content Tools). However that doesn't change the fact that, as far as I know, there's no supported way to execute an expression rule by its name. (edit: Mathieu mentions below that the function "getrulereferencebyname" can do this. however as noted, this is cumbersome and confusing to use, and relies on old / potentially-deprecated features.)
This is why Mathieu raised the idea yesterday of executing Web API calls - because for these it's trivially easy to execute a call based on just the result of a string look-up (the API endpoint name is already just a string), and the other end of the API call can be paired to a Web API that points to its own expression rule (so if each person makes an expression rule for themselves, they'd also make a Web API object that calls it, and requires certain universal parameters that you enforce). Thus you'd just store the Endpoint Name in the DB.
Hi Actually you can execute the rule by its UUID/Name.
Yeah as I mentioned earlier, it is possible to do with the apply function.
Though I do get the impression that Appian may want us to move away from using this function given the blurb they put at the too strongly suggesting to use forEach instead.
Not required to use apply function
Interesting. Care to elaborate?
For those wondering, here's an example of what I meant using the apply function in combination with the getrulereferencebyname in the Content Tools plugin.
Again, I don't recommend this approach as it becomes very difficult to find dependencies in your application and troubleshooting becomes difficult. The API approach is more robust IMO.
a!localVariables( apply(getrulereferencebyname("S_DynamicRule"), {""}) )