Pass value from selected item into query

New user here so forgive my naivety and inexperience. I have a form in which the workflow culminates in an insert statement executing to create a record in a MySql database. I am familiar with passing in a {{ select1.value }} into the SQL statement as a param but what I would like to do is to pass in additional data retrieved in the same query that supplies values to a specific dropdown. In my instance I need to pass in a Host Name, EmailID and an additional ID that all derive from a single query vs. creating three discrete select dropdowns to do so. The {{ select1.value }} successfully inserts the HostName but despite apparent values being returned for the other two parameters {{ select1.selectedItem.EmailId }} I am encountering an error in the SQL syntax. Any suggestions as to how I can successfully pass in three distinct values by reference to a single select dropdown? Thanks!

Hello @Miah2877,

Welcome to the forum!

When using a select dropdown to populate multiple parameters in a SQL statement, you need to use the selectedItem property to access the selected item's data. The selectedItem property is an object that contains the selected item's value, label, and any other custom data that you have defined.

In your case, you can access the selected item's EmailId and additional ID using the following syntax:

{{ select1.selectedItem.EmailId }}
{{ select1.selectedItem.additionalId }}

Here is an example of how you could use this syntax to pass in three distinct values by reference to a single select dropdown:

INSERT INTO table_name (host_name, email_id, additional_id)
VALUES (
  '{{ select1.selectedItem.hostName }}',
  '{{ select1.selectedItem.EmailId }}',
  '{{ select1.selectedItem.additionalId }}'
)

Hope this helps!

:grinning:

Patrick

@PatrickMast thanks a million!

1 Like