Hexagon Geospatial
MENU

M.App Enterprise

Discuss topics with other M.App Enterprise Product pioneers and experts to get the most out of it.
Showing results for 
Search instead for 
Do you mean 
Reply
Frequent Contributor
Posts: 155
Registered: ‎01-14-2018
Accepted Solution

Making combobox read based on other combobox depending on foreign key in M.App Enterprise

[ Edited ]

Dear all, 

 

In M.App Enterprise Workflow, I have the following case:

a polygon feature called 'parcels', and 2 tables ('Uses', 'Classes') as you can see in the image below

 

tables.PNG

 

In my workflow I have a form for the polygon feature 'parcels' inwhich the user should choose for each parcel its 'uses' and 'class'  from 2 comboboxes.

 

 

tables2.PNG

 

 

So I have 2 questions:

  1. I want in the first combobox to show the uses column (column type: character varying) in the uses table (I know that I can do that from the list of values through sql). The problem will appear in the coming point
    I want to show a text but actually it saves an integer; I know I can use 'static list', but it's static; I may add a new row in the uses and It is not applicable to add a key and value in M.App Enterprise for each row added in the database.
  2. I want the 2nd combobox  to update its fill based upon the choice of the 1st combobox (based on the foreign key relations in the database)

 

Best regards

Khaled

Staff
Posts: 1,000
Registered: ‎10-19-2015

Re: Making combobox read based on other combobox depending on foreign key in M.App Enterprise

Hi Khaled,

 

it's not clear to me what you want to achieve, just a couple of notes:

  • in a combobox you always use a key/value pair:
    • SQL:
      • select key, value from table -> stores key in the combobox and shows value
      • select key from table -> stores and shows key
    • Fixed: key1, value2; key2, value2 -> stores key1 or key2 and show value1, value2
  • using a form placeholder you get always the dependent fields refreshed when the user selects a value; so in your use case something like:
    • <FormField name="NewTextfield1" datatype="string"  type="textfield" />
      <FormField name="NewComboBox1" datatype="string" lov="SQL[select case {FORM.NewTextfield1} when 'one' then 'one' else 'zero' end]" type="combobox"/>
      <FormField name="NewComboBox2" datatype="string" lov="SQL[select case {FORM.NewComboBox1} when 'one' then 'ok' else 'no' end]" type="combobox"/>
      

HTH,

Stefano

Stefano Turcato
Presale Engineer
Hexagon Geospatial
Frequent Contributor
Posts: 155
Registered: ‎01-14-2018

Re: Making combobox read based on other combobox depending on foreign key in M.App Enterprise

[ Edited ]

Thanks Stefano,

 

The select key, value from table solved my first question.

 

In my second question what I want is to:

filter the 2nd combobox list of values based on my choice in the 1st combobox depending on the foreign key relationship between the 2 tables, for example:

 

If In 1st combobox  if I choose 1 Agricultural -> the  2nd combobox  should only show A and B

and if I choose 2 Industrial ->  the  2nd combobox  should only show C and D.

 

As a summary for my case: I solved the first question as follows:

in List of Values sql: select id, uses from uses

 

I solved the second question as follows:

in list of values sql: select id, class from classes where "fk_usesId" = {FORM.uses}

 

Kind Regards

khaled

Do you need immediate support?
If you encounter a critical issue and need immediate assistance please submit a Development Ticket through our Development Ticket Portal.