How to initialize a Structure in OutSysten

How to initialize a Structure in OutSysten

  

I have a need to populate a database from a List. I need to construct a temporary database Structure from the list record + external information. This structure is the parameter to the Create function of the table. This is done in a loop until all records of the List is processed.

Question: How do I reinitialize the Temporary Database Structure between each iteration in the loop. I have to do this so that data from the previous record is not mixed with the current.


Sudo code

UserProfile tmpProfile;

for ( item on itemList) {

tmpProfile = new UserProfile()   // how do I do this in OutSystems

//assign values to fields of tmpProfile

createRecord(tmpProfile)

}

Thanks

Hi Kishan,

I'm not sure I understand your question. There aren't "database structures" in Outsystems. If you need to store information in the database, you have to use an Entity.

If you use a temporary variable of your entity's type as an input parameter to the Create action, there's no need to "initialize" it. Simply assigning the new values should be enough.

Hi Kishan ,

I undestand you hava an tmpProfile as local variable in your context and its type is UserProfile.

Inside the for you need to reset the values of this variable. 

There are 2 easy way to do it:

First you can made your assign and be sure that all fields has been replaced for the values you filled in the last interation


Other way, is create a secondary local variable , ex: EmptyProfile of UserProfile type.

So you assing tmpProfile = EmptyProfile when you need to initialize it.



 



Kishan Siram wrote:

I have a need to populate a database from a List. I need to construct a temporary database Structure from the list record + external information. This structure is the parameter to the Create function of the table. This is done in a loop until all records of the List is processed.

Question: How do I reinitialize the Temporary Database Structure between each iteration in the loop. I have to do this so that data from the previous record is not mixed with the current.


Sudo code

UserProfile tmpProfile;

for ( item on itemList) {

tmpProfile = new UserProfile()   // how do I do this in OutSystems

//assign values to fields of tmpProfile

createRecord(tmpProfile)

}

Thanks