Server actions can be functions but screen actions cannot be functions. Is there a way to deploy a function screenside?


In my case I want to paint the background of a table cell different colors depending on a condition. I already have a server action (function) that does this and I call it during screen preparation for use outside a table. All I have to do is call the function, with one input parameter, and then use the output. But, I cannot call a server action from the table cell and cannot build a screen action that is a function. Is there a proper way to have a function call from inside the table cell? I am trying to use a style property and assign a function output to it.


Thanks.

Solution

Hello Bill,

You can use functions in screen and also in widget properties. Also, you can do conditional style. 

From another post (Thanks Tiago Neves):

You can use the Extended Properties and assign "style" as property and in the value use logic (you can use Built-in or even User Functions) like a simple If and have an On Change Action make an Ajax Refresh of the widget.

So, refreshing the widget, or the line, in case of a table, will execute the function/expression and update the style/class.

Cheers

Solution

Hi Bill,

A Screen Action is an Action that is called by Screen Elements, e.g. a Button or a Link (or by a Widget as part of a Notify). It has direct access to the Screen's Variables and Preperation. Since Screen Actions are always "triggered" so to speak by user input, it makes sense they can't be Functions, as Functions are used in Expressions.

That said, as Eduardo wrote above, you can call Functions that you have defined elsewhere (in the same eSpace or referenced from another) everywhere you can put an Expression. But since the aren't "local" to the Screen, you will need to pass any data you need that is local to the Screen like its Variables and Preperation elements as Parameters.

Thanks to both of you. I had already written a function. I thought it unavailable in the screen (and widget) since I could not see it. With your feedback I finally figured out to open the "User Functions" folder.


Thanks again.