How do I create a list from records selected in a record list?

How do I create a list from records selected in a record list?

  

Hi all

using the web apps platform. i have ‘list records’ table with checkboxes. I am able to delete records by selecting multiple and deleting. This was created automatically from outsystems for me. This is the action that was created

My question is how do i now use this functionality to do something else. Example: I want to bulk edit various attributes of the selected row/records all at once. So things like changing the phone number or surname of 4 records all at once. Can someone please help me? Thank you.

Beau Clear wrote:

Hi all

using the web apps platform. i have ‘list records’ table with checkboxes. I am able to delete records by selecting multiple and deleting. This was created automatically from outsystems for me. This is the action that was created

My question is how do i now use this functionality to do something else. Example: I want to bulk edit various attributes of the selected row/records all at once. So things like changing the phone number or surname of 4 records all at once. Can someone please help me? Thank you.


Should I creat a list from selected record id?

Try to use the same mechanic with a little twist.


Use ListFilter on your widget. (you might need to reference it in Systems)
Condition : where selected = true

Use StringJoin Server action from the Text extension. (referencing it will be required)

Stringjoin the result of your ListFilter action with the ID. (use the id as value and a comma as separator)
You'll now have a string variable with a concat of the id's you selected. for example
'1,2,3,4,5,6'

You'll be able to use that string variable in an advanced SQL to perform bulk operations using the 'WHERE IN' clause. (best practice for bulk operations)

For example:

UPDATE {table1} 
SET {table1}.[AttributeName] = @newValue 
WHERE {table1}.[ID] IN (@StringValueWithIds);


@StringValueWithIds is an input parameter from the advanced SQL. Set expand inline property to 'yes'.
Give the StringJoin result to that input parameter so it can be used in the WHERE IN clause.


If you have a hard time accomplishing it, then i'll make an example espace to get you started.

Greetings,
Niels F.

Hello Beau,

Niels is assuming that you wants to set the SAME value in a field for different records.

If you want to set different values in one or more attributes of more than one record, and execute a single action to update them in database, this approach will not work.

In this case You can Filter the list based on an attribute, like an "IsUpdated" or something, and iterate this list to update the records in database.

Cheers

Niels Favreau wrote:

Try to use the same mechanic with a little twist.


Use ListFilter on your widget. (you might need to reference it in Systems)
Condition : where selected = true

Use StringJoin Server action from the Text extension. (referencing it will be required)

Stringjoin the result of your ListFilter action with the ID. (use the id as value and a comma as separator)
You'll now have a string variable with a concat of the id's you selected. for example
'1,2,3,4,5,6'

You'll be able to use that string variable in an advanced SQL to perform bulk operations using the 'WHERE IN' clause. (best practice for bulk operations)

For example:

UPDATE {table1} 
SET {table1}.[AttributeName] = @newValue 
WHERE {table1}.[ID] IN (@StringValueWithIds);


@StringValueWithIds is an input parameter from the advanced SQL. Set expand inline property to 'yes'.
Give the StringJoin result to that input parameter so it can be used in the WHERE IN clause.


If you have a hard time accomplishing it, then i'll make an example espace to get you started.

Greetings,
Niels F.


Hi Niels

thanks for your offer but i will attempt to make sense of it first. This is first time using these actions so unsure but happy to learn.

So far I have start> list filter>string_join. I have put “,” in separator but i think im missing a step because the ‘List’ parameter is asking for a ‘Text Record List’. I need to convert records to list first?

Eduardo Jauch wrote:

Hello Beau,

Niels is assuming that you wants to set the SAME value in a field for different records.

If you want to set different values in one or more attributes of more than one record, and execute a single action to update them in database, this approach will not work.

In this case You can Filter the list based on an attribute, like an "IsUpdated" or something, and iterate this list to update the records in database.

Cheers

Hi eduardo

yes this is correct in what i am trying to do, set same value in a field for different records that have been selected from a table record

thank you


Solution

Hi Beau,

You can ofc not use Advanced SQL and use a loop instead and update them one by one.
But for bulk operations it's recommended to use this scenario. (UPDATE SET, WHERE IN )

https://success.outsystems.com/Documentation/Best_Practices/Performance_Best_Practices/Performance_Best_Practices_-_Queries#Use_SQL_queries_for_bulk_operations


For this case it's maybe overkill, but it's not a bad idea to make it a habit by using it this way :p


See OML attached.
It's a simple example.


Solution

Hi Niels,

Youre an angel! It works, not exactly how i thought it would but im able to achieve the same outcome and i think this way will be better like you said in the long run. this was my first time using SQL and it's seems really efficient. Im going to have a play around and look at the documentation you attached

thank you very much

Niels Favreau wrote:

Hi Beau,

You can ofc not use Advanced SQL and use a loop instead and update them one by one.
But for bulk operations it's recommended to use this scenario. (UPDATE SET, WHERE IN )

https://success.outsystems.com/Documentation/Best_Practices/Performance_Best_Practices/Performance_Best_Practices_-_Queries#Use_SQL_queries_for_bulk_operations


For this case it's maybe overkill, but it's not a bad idea to make it a habit by using it this way :p


See OML attached.
It's a simple example.



Just another question,is there a way to change the attribute thats being edited? through a variable maybe? would it become set {companymembers}.[@VariableName] = @ChangeTo ?