How can I access an output from a server action, in my screen?

I have a server action that fetches some data on the DB and outputs a record. 

 I


On my screen I created a variable to store this data, however I'm falling to connect the two. 


The idea behing is that I fetch the DB for the record once I press a button, and retrieve the cheapest room available. 

Can anyone provide me a solution to overcome this scope problem? 

Many thanks.

Hi Tiago,

You need to create a client action for button and on that client action you can call your server action.

To hold the server action results, you can create local variable as a same type of server action output parameter.

Thanks

Vinod


Hi Tiago

Add this assignment and then check 


Also if doesnt work than please share BookingCore_TRU module as well . reference is missing

Best regards

Devendra


HI Taigo,

Use the Data Action and call the server action from there and change the out put of the Data Action to the CheapestRoom Structure and assign the Value of Server action to the out put of the Data Action

Data Action is used to send the data from Server to Client


Now use the Data Action out put to assign to the UI elements

Please find attached oml check the DataAction page. 

Best Regards

Devendra

TestJob.oml

Hello Devendra, 

I've tried to use your solution, but  I did what you told me and created the data action, however, I'm unable to set the Output type of the data action.

In this case I cant find a suitable output type.

Not sure if I'm doing some mistake. 

mvp_badge
MVP

You have correctly set the data type, now you need to add an assign after the GetCheapestRoom action. In this assign, you fill Out1.

Hey Remco,

I did that, but now I'm not able to assign the Data Action to the Onclick of the button.

Hi Tiago,

You need to create a client action for button and on that client action you can call your server action.

To hold the server action results, you can create local variable as a same type of server action output parameter.

Thanks

Vinod


Hey Vinod, 

I have done that as we previously discussed, however the button has stoped working. 

The primal reason for this I believe, is that the output of the Server Action is not being used, as you can see on the pic (I might be wrong):

After that I assign the output values to the Local variable:

Bur for some reason this doesnt work. 

Thank you



Hi Tiago,

In your server action Getcheapestroom you are calling a SQL query but output of that is not assigned to out put of server action.


hey Devendra,

I reflected on your answer and into my understanding I'm not able to assign the output of the GetCheapestRoom Server Action to my screen var due to scope restrictions: 

But maybe I'm missing out something here. 

Thanks for your help.

Bookings_TRU.oml

Hi Tiago

Add this assignment and then check 


Also if doesnt work than please share BookingCore_TRU module as well . reference is missing

Best regards

Devendra


Also you are not using GetCheapestRoom server action and CheapestRoom structure in your screen you are using GetBookingByList aggregate See below image



HI tiago,

First set the Dataaction Fetch property to Only on Demand

And then on Button Click Event Refresh the DataAction by Just Drag and drop there


Also check your form inputs are assigned to the Data Action Out Attributes.


Best Regards

Devendra

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.