17
Views
6
Comments
Solved
Identify column name dynamically for mapping
Question
Application Type
Mobile

Hi,

I have 5 buttons each represent a column in an Entity. If a button is pressed, i need to update that column with some value.

I dont want to put an if else condition to check what value returned on pressing each button and then update that column.

Is it possible to pass the value of the button to identify the column in the assign mapping, so that i donot need any conditions to check the column?

Thanks

Siva Kumar

Rank: #56
Solution

Hi Siva,


You can have the column name passed as a parameter with the property Expand Inline set to True.


So in this example, if the ColumnToUpdate value was "{User}.[Is_Active]", it would update the Is_Active attribute to True.


In your case, you can have a query similar to this and have the field to update as an input and call the same screen action doing the update just passing a different parameter according to the column to change in each button. 


Take into account though that using Expand Inline parameters is error-prone (Service Studio won't help you validate the syntax since it doesn't know what you are going your parameter value), does not allow the optimization of execution plans and can expose your code to SQL injection.


Hope it helps.


Regards,
João

Rank: #9358

Hi João,

I am not using an sql query here. I am using a update server action using a record set as input. Can i achieve this here?

Rank: #56

If you're not using a SQL query you'll have to use the ifs or a switch which is basically the same.

Rank: #9358

Hi João,

I used the sql query and it worked fine. Thanks for the help.

Just one question on this context. Is it possible to identify if a particular row os returned based on the value of a column.

Ie, i used an aggregate to list all bookings for a month and now if i want to check if a booking is present for a particular date, can i check that directly in a condition without looping?

Thanks

Siva Kumar

Rank: #56

Hi Siva,


I'm glad I could help. Please consider, if it solved your problem, to mark the above answer as solution so other developers can find help if they run into a similar issue.

Perhaps, you want to consider using the ListAny or ListFilter actions(from System) and do this check after the query:

 

Regards,
João

Rank: #297

Hi siva kumar


Set Expand In Line to true is very risky. Make flow simple is not a nice reason to take the risk.

It's also against best practice, Please refer Url below.

https://success.outsystems.com/Documentation/Architecture_Dashboard/Code_Patterns/Best_practices/Don't_abuse_expand_inline_parameters

Regards