Cant copy RecordList.current to another RecordList.current

Cant copy RecordList.current to another RecordList.current

  
Hello all,
this seemed simple and obvious enough to me but...im missing something for sure.

Context:
Type A RecordList;
Custom structure type B in which one of the Attributes is a Record type A;

Im getting a type A RecordList from a certain query, and i am trying to copy every Record of that list onto a local RecordList of type B's attribute. For example:

TypeA:
text attribute
int attribute

TypeB:
TypeA attribute
text attribute

I get a recordList of type A's:

[0] -> "this is text"; 1
[1] -> "this is also text"; 2 

And copy to a recordList of type B's:

[0] -> "this is text"; 1; "typeB text"
[1] -> "this is also text"; 2; "TypeB another text"

I tried to just do:

ForEach(TypeA)
Assign(TypeB.current = TypeA.current)

And it seems like the typeB.current isnt incrementing, and i cant find a way to do so. Meaningi can cycle through the TypeA list but not through the TypeB list.

Im sorry if this is confusing...



Rui,

Look in the systems references for the ListAppend action.

When just using an assing as described above, you always set the Type A record to one Type B record. So you're looping trough each record of A but not to each record of B.

Kind regards,
Evert
Rui,

One way of doing what you want is to do a manual increment of one of the RecordLists inside the ForEach
using your example it would be something like :

Assign(TypeB.current = RecordListTypeA.List[incrementvalue] for the text and number
and increment the variable incrementvalue, obviously you need to control really well the number of records you have in structure A and in structure B so you don't get index was out of range erros given the case of structure A and structure B don't have the same number of records.

Regards,
João Coelho
Hi Rui,

Use the ListAppend to append a record of TypeA RecordList into TypeB RecordList, supposing that Type B RecordList is empty.
You can always work with indexes, to sync both RecordList, but make sure they must have the same size, to avoid out of bounds exception.

Regards.
Pedro Ávila
Thank you all, the ListAppend was just what i needed. Didnt know that existed.
I just created a temporary record to put the values in and then append it to the record list. Seems to work fine.

Thanks again!