Its Possible Show 1 field of each database in a dropdown?

Its Possible Show 1 field of each database in a dropdown?


if it's possible? how to make?


Hi David,

What do you mean by "each database"?

Dropdowns (mobile) just need a list, and you can have this list from aggregates, SQL, or even local variables (List of Something) that you can use ListAppend to append items to it.

Cheers.

Eduardo Jauch wrote:

Hi David,

What do you mean by "each database"?

Dropdowns (mobile) just need a list, and you can have this list from aggregates, SQL, or even local variables (List of Something) that you can use ListAppend to append items to it.

Cheers.

i mean i have 2 tables like this 

And i need to group the 2 fields " nome" and "designacao_social" in a single dropdown

to show their records


these two fields together in the same dropdown

Hi David,

I already told you the solution in private message but I will leave it also here for others.

If you want to join those in same dropdown you need to join those 2 lists in 1. the simplest way of doing this is create a a generic list and append both lists to it. This generic list should be of a structure that contains 3 fields: Id, Description, Type.

  • Id -  This should be the Client Id or the Company Id 
  • Description -  This will contain the name of the Client or the Name of the Company
  • Type - This should be or client or company. This way you know of what type of the record selected

Regards,

Marcelo

Hi David,

You can create a structure with 1 attribute type Text. Then create a list with that structure.
After that, you can create 2 different aggregates for "nome" and "designacao_social" records then ListAppend results to your structure.

But also, you must consider that do you need Id fields also? If you need you should also add Id to your structure and of course EntityDefinition like "Nome" and "Designacao"

Hope it helps.

With best regards,
F.Karatay

Hi David,

I will tell you that, for a start, you have a bad data model.

ClienteNormal and Empresa are basically the same things? Like, both of them are clients, right? Only one is an individual, and the other is a company? They have the exact same information, only the name of the fields changes. So, I would change the data model to be something like this:

I would "merge" both entities. And use an FK for a Static Entity to identify if it is a Company or an Individual.
If I need extra fields unique to one or other type of client, I would use extension entities, like IndividualClient and CompanyClient. When fetching data I could join with those extensions depending on what I am looking for, and I could filter data based on the type of client, etc.

Then you would be able to just feed the Dropdown with the result of a simple aggregate.
No extra work with logic or whatever required.

BUT...

If for some reason, you CAN'T change your data model, then I would also avoid creating local lists and append things, just because you don't need it. A simple Aggregate is perfectly fine to fetch the information you need using a small trick.

Like this:

What are we doing here?

1. We are doing a FULL OUTER JOIN (With) between both entities, guaranteeing that we will never have a match between the lines of both entities (the 'AND False') part on the JOIN clause. This will create lines that have ClienteNormal filled and the Empresa not filled, and lines where Empresa data is filled and ClienteNormal is not filled.

2. We then create a computed field that will have the designation of NormalCliente or Empresa depending on who is available on that line.

Because you can have the SAME ID values in both entities, but you need to be able to select one of the items (or the dropdown would be stupid), you need to have a way to save the ID when selecting an item, but at the same time, know if the selected item comes from ClienteNormal or Empresa.

3. Create another computed field that will do the same thing we did for the designation, but for the id. And then add a "1"+ or a "2"+ to it, so that it creates a TEXT field and later on you can take that part to identify which one was chosen (ClienteNormal or Empresa), and also have the ID of the selected record.

Then in your dropdown you can choose both the attribute you wants to show (Name), and store the Identifier in the associated variable (that now must be a text variable). You can create a function that receives this text and returns from which table came the selected item and an integer with the id that you can use later on.

Hope this helps :)

Cheers.

Hi David,

Have you solved your issue? If so, can you mark as solution the post that answered your question? If you followed a different approach, can you share it with us, so that everyone can learn from your experience?

Thanks!