Getting data from Database

  

Hi all,

I am able to send data from my app to my database like so:

I am now trying to extract for example the Name at Id "7" by using aggregates in the flow like so:

However I am unable to add an entity to this aggregate. I suspect I am missing something really simple but I cannot tell what it is. Thank you.

Regards,
Jerome


Hi Jerome,

From the looks of it, you are in a client side action using an aggregate. When using an aggregate in a client side action, you are only able to add local entities. 

What you will need to do in this circumstance is add a server action, and add the call to the database inside of that action, or if you already have the data fetched (right click on screen and choose 'Fetch Data from Database' option), you will be able to use a refresh data call to that aggregate directly inside of the client action.

Let me know if this helps,

Justin


Justin Babel wrote:

Hi Jerome,

From the looks of it, you are in a client side action using an aggregate. When using an aggregate in a client side action, you are only able to add local entities. 

What you will need to do in this circumstance is add a server action, and add the call to the database inside of that action, or if you already have the data fetched (right click on screen and choose 'Fetch Data from Database' option), you will be able to use a refresh data call to that aggregate directly inside of the client action.

Let me know if this helps,

Justin

Hi Justin,

Thank you for your reply. I have tried what you said but I have failed to get the data from the database. This is my diagram:

I was unable to find much info about how to specify the id of the database in order to grab the data "yoyoyo" and assign it to a variable. Do you know how to achieve it? Thank you.

Regards,

Jerome 


Hi Jerome,

Can you share your OML so I can show you exactly how to do this in the context of your code?

Thanks,

Justin

Justin Babel wrote:

Hi Jerome,

Can you share your OML so I can show you exactly how to do this in the context of your code?

Thanks,

Justin

Hi Justin, 

I have attached my OML to this reply. Thank you so much.

Regards,

Jerome 


Hi Jerome,

The problem is in your "GetDBName" action's Id input parameter. If you want to display the name whose Id the user entered into the input, you need to pass that Id to the action. Try changing the expression for the Id input parameter to the following:

TextToInteger(ShowName)

Hi Jerome,

While I am unsure of what you are using to determine what record's name should be shown when clicking the 'Show Name' button, based on what you are doing right now, you want to save a record by entering a value in the input, click the save button, and then when you click the 'Show Name' button, it will show the name of the most recently saved record.

In order to achieve this, you need to set the Id of the local variable 'NameDB' after you create the DBName record on save. Otherwise, you are getting on a null id, which will throw an error. Also, this id will always be null unless saving a record, the current way you have it set up.

Let me know if this is not what you are trying to achieve,

Justin

Hi Justin, 

That is indeed what I am trying to achieve and I do not understand why I am struggling to understand this. I have since added another box to specify the ID of the variable I would like to take from DBName. However every time I try to assign NameDB.Id, it asks for a NameDB Identifier, and if I assign a NameDB Identifier type variable to an input, an error would appear. Am I approaching this is a wrong way? 

Thank you for your help. Its really embarrassing that I am struggling so much with this.

Regards,
Jerome

Aurelio Santos wrote:

Hi Jerome,

The problem is in your "GetDBName" action's Id input parameter. If you want to display the name whose Id the user entered into the input, you need to pass that Id to the action. Try changing the expression for the Id input parameter to the following:

TextToInteger(ShowName)

Hi Aurelio,

I think the area where I am struggling in is in specifying the ID as it asks for the database identifier. However I am unable to assign it as it asks for a database identifier type variable which I cannot assign to an input.

Regards,
Jerome


Solution

Hi Jerome,

You can assign an integer value to a database identifier variable. Service Studio will show a warming message, but it should work.

Solution

Aurelio Santos wrote:

Hi Jerome,

You can assign an integer value to a database identifier variable. Service Studio will show a warming message, but it should work.

Hi Aurelio,

Thank you, I have been struggling for days.

Regards,

Jerome Lieow