92
Views
5
Comments
Solved
Retrieve a specific value from database and pass it to a variable
Question

I'm new to Outsystems and I'm still figuring out the syntax and ruling of the expression.

For context, I want to update multiple variables when a dropdown list was changed. My logic goes as follows:

- Once the user selects an option, the value of that option (which is id in database) is passed to a variable. 
- Using onChange handler, I want to access a certain value in the database based on its Id and column name. The passed value will be used as Id and the column can be manually declared.
-  Retrieved value is passed to another variable.


image_2024-05-23_165009147.png
UserImage.jpg
John Dulosa
Solution

After 5 consecutive shots of coffee and cursing that can make a sailor want to adopt me, I figured out a clanky but working method of filtering:

1. Input sends the system generated Id to local variable
2. Upon clicking next, a client action is declared
3. Form is verified and the following formula is used while assigning value to another variable:
    - Index the Id inside the database using "Index(//database.Colname//, //retrieved ID//)" 
    - List all the data from database using "Get***.List"
    - Combine all functions: Get***.List[Index(**,**)]
    - Declare the database and the specific col of the data that needs to be retrieve: Get**.List[Index(**,**].//Database//.//ColName

While I use Index in this example, I end up using IdentifierToInteger just to make it usable for array.

As much as I just want to automatically send the data to database, form type web needs multiple pages and submission control. So yeah very clanky.

image_2024-05-24_162547201.png
2024-04-26 12-21-07
Anjali_Dange

Hi John,

You should include the local variable in the dropdown properties, then incorporate it into the aggregate filter to retrieve the desired data. Utilize the OnChange action of the dropdown to update the aggregated data with the added filter IDs.

This will fetch dynamic data from database based on values from the dropdown.

Regards,

Anjali

UserImage.jpg
John Dulosa

But the issue still stands, what syntax to use in order to use the id (sysgen id) from a variable to retrieve the 3rd column in the database. I need to separate the digestible data from functional data (system logic strings and ints), hence the need for multiple variable setup in 1 function.

2016-04-21 18-13-58
Nuno Rolo
 
MVP

Hi John,

Considering your doubts I strongly advise you to go through this training.

Hope this helps.

Nuno Rolo

2024-05-14 05-39-17
Jothikarthika - EONE

Hi John, 

1.Refer below link for to get more information about client variable

https://success.outsystems.com/documentation/11/reference/outsystems_language/data/handling_data/client_variable/

2.

Dropdown property window

variable:To store selected value of dropdown

List: List of the option shown in dropdown option

option text-show option text

option value-selected option value 

option value,Variable will be same datatype

3.Refer below URL for get selected product  detail 

https://personal-3jlegpjt.outsystemscloud.com/poc/Dropdown?_ts=638521450998581800


UserImage.jpg
John Dulosa
Solution

After 5 consecutive shots of coffee and cursing that can make a sailor want to adopt me, I figured out a clanky but working method of filtering:

1. Input sends the system generated Id to local variable
2. Upon clicking next, a client action is declared
3. Form is verified and the following formula is used while assigning value to another variable:
    - Index the Id inside the database using "Index(//database.Colname//, //retrieved ID//)" 
    - List all the data from database using "Get***.List"
    - Combine all functions: Get***.List[Index(**,**)]
    - Declare the database and the specific col of the data that needs to be retrieve: Get**.List[Index(**,**].//Database//.//ColName

While I use Index in this example, I end up using IdentifierToInteger just to make it usable for array.

As much as I just want to automatically send the data to database, form type web needs multiple pages and submission control. So yeah very clanky.

image_2024-05-24_162547201.png
Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.