How is your experience with the OutSystems Community?
23
Views
6
Comments
Solved
How can I reset a Structure variable to its default values in OutSystems?
Application Type
Traditional Web, Mobile, Reactive

Hi everyone,

I know that a List variable can be cleared by using the ListClear action.

However, I'm not sure how to reset a Structure variable.

For example, I have a local variable named `SearchCondition` with the data type `WarehouseBoxPackingMaterialItem`.

It contains multiple attributes such as:

- LGNUM

- WERKS

- LGORT

- MATNR

- MAKTX

- ZREPAIR

- ZBQTY

- BOXSIZE

- BOXCNT

- VERME

- MEINS

- CHARG

- BOXNO

After using this variable, I'd like to reset all of its attributes back to their default values (empty strings, zeros, False, etc.).

Is there a built-in way to initialize or clear a Structure variable, similar to `ListClear` for Lists?

Or is the recommended approach to assign each attribute individually?

Any advice would be appreciated. Thank you!

2026-06-20 17-43-43
Sherif El-Habibi
Champion
Solution

There is actually a workaround. You can create a local variable of the same structure type and leave it with its default (empty) values. Whenever you need to clear the values of another variable of that structure (the one you are using), simply assign the empty local variable to it. This will reset all of its fields to their default null values.

2026-06-20 17-43-43
Sherif El-Habibi
Champion

Hi @sangwoo jee,

I’m not sure there’s a built-in way to clear all of them automatically.

The approach I know is to explicitly assign each attribute back to its corresponding null value.

UserImage.jpg
sangwoo jee

I can't believe it.

Is there no action that performs a similar function to ListClear?

2026-06-20 17-43-43
Sherif El-Habibi
Champion
Solution

There is actually a workaround. You can create a local variable of the same structure type and leave it with its default (empty) values. Whenever you need to clear the values of another variable of that structure (the one you are using), simply assign the empty local variable to it. This will reset all of its fields to their default null values.

UserImage.jpg
sangwoo jee


감사합니다.


저는 이미 그 방법을 사용하고 있지만, 제 아마추어적인 실력이 그대로 드러나는 것 같아서 제대로 하는 방법을 알고 싶었습니다.

2026-06-20 17-43-43
Sherif El-Habibi
Champion

As far as I know, there isn't a built-in way to clear a structure in OutSystems. Assigning an empty instance of the same structure is the standard approach, so you're not doing anything wrong it isn't an amateur solution.

2021-09-06 15-09-53
Dorine Boudry
 
MVP

marked @Sherif El-Habibi  answer as solution.

as he said, there is nothing amateur about this.  

If you are using this same structure all over your application and often need to reset it to default, you could make your code a little cleaner (no extra local variables all over the place) by creating a little helper function that exports this structure and does nothing to it. 

Or one step further, if you often want to initialize certain fields to some non default value in the same way (like userid to logged in user, datetime to currdatetime, some code to some site property,etc...)  that function can do that for you as well and make it consistent all over your application.

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.