Generate Appian Function From Text

Hello, 

I have a use case where end users must be able to define "functions" that will be applied to values defined in the application. 

I was wondering if it was possible for the end users to write an Appian function with SAIL format in a paragraphField and then "translate" the generated text into an actual function ?

Is it possible maybe thanks to Appian Java API ? 

Thank you in advance,

Claire

  Discussion posts and replies are publicly visible

Parents
  • 0
    Certified Lead Developer

    Bad idea. Appian has no way to restrict that to certain functionality so your users might do malicious things.

    A while ago I had to create a rating mechanism which enabled users to take values of fields and do certain calculations on each. The sum of weighted results is stored as rating.

    Similar functionality can be implemented with a bit of effort. A table in DB holds all the calculations for each field. Users have a UI to define this. Some looping logic evaluates these definitions.

    Would that fit?

  • 0
    A Score Level 2
    in reply to Stefan Helzle

    I understand your point. 
    I'm not sure to understand correctly your solution though : is the table storing formula with corresponding evaluated values ? 

  • 0
    Certified Lead Developer
    in reply to Claire

    I can't speak for Stefan but the impression I got was that he was suggesting something close to a palette of available calculations on a particular field or set of fields, where you allow a user to fill in one or more values then choose an operator (i.e. from a dropdown), and then use a bit of kludgey / manual logic either in a DB view or, in my opinion, the same could be done directly on-form in Appian, to display the result to the user.  Of course this all depends on the desired operations being relatively uncomplicated, unless you want to sink loads and loads of time into developing it.

    I'm not sure how much this matches your use case, honestly - it sounds almost as if you've been tasked to build a SAIL parser within SAIL.  Such a thing is... certainly possible... but labor intensive, to the point that I'd be very hesitant.  A shortcut (undocumented function) which everyone will tell you to avoid at all costs at least in a production system, but which you could test out at least for a proof of concept, can be read about here.  I won't name it because I don't wanna get yelled at Worried

  • 0
    Certified Lead Developer
    in reply to Mike Schmitt

    Mike! Shame on you !

    The solution I built works like this

    Iterate on all fields of a CDT. For each field look for formulas (Simple operations like +, -, * /, etc) stored in DB. Evaluate each formula (e.g. if there is a "+" in DB add a static value). Then sum up all the results.

    A UI allows users to configure these "formulas". Example: If the value in the field "value" is between 5 and 10, then add 42 to the final result. I added weighting to make some fields more important than others.

    Does that make sense?

  • 0
    Certified Lead Developer
    in reply to Claire

    He's speaking of the undocumented feature I call the evil function (not how it's spelled but how it should be pronounced).  It takes text, treats it like code, and runs it.  All languages that support their version of the evil function suggest avoiding its use wherever possible, and I couldn't agree more. A user could literally write ANYTHING and it would run, such as making themselves into Admins or any number of other horrible things they could do.

    Now, to your particular quandary.  It all depends on what you want to do.  If you want your functions to be far too complex, it might have to be a submission form that can be sent to developers to check and implement.  If you want instant feedback, you may need to have users select from a limited set of building blocks and see what you can arrange in the code.

    It might be possible to string together 5 or 6 simple mathematical operations, or some text operations, but the more diverse the harder it will naturally be to implement.  Have your clients provided an example of the kind of function they'd like the user to be able to make?

Reply
  • 0
    Certified Lead Developer
    in reply to Claire

    He's speaking of the undocumented feature I call the evil function (not how it's spelled but how it should be pronounced).  It takes text, treats it like code, and runs it.  All languages that support their version of the evil function suggest avoiding its use wherever possible, and I couldn't agree more. A user could literally write ANYTHING and it would run, such as making themselves into Admins or any number of other horrible things they could do.

    Now, to your particular quandary.  It all depends on what you want to do.  If you want your functions to be far too complex, it might have to be a submission form that can be sent to developers to check and implement.  If you want instant feedback, you may need to have users select from a limited set of building blocks and see what you can arrange in the code.

    It might be possible to string together 5 or 6 simple mathematical operations, or some text operations, but the more diverse the harder it will naturally be to implement.  Have your clients provided an example of the kind of function they'd like the user to be able to make?

Children
No Data