fromCollection with Key not updating


I have a problem with the code below. I’m using fromCollection to update a [DjFields] from Mysql. The first time I run this loop and [DjFields] is empty the records are created as expected because I do not pass the UUID as the $GroupsUUID array is always empty .

The second time I run the loop I check for UUID in [Djfields] and add this to the object in the collection.

According to the documentation. “If the primary key is given and exists, the entity is updated. In this case, the primary key can be given as” however with the code below this not the case duplicate records are created each time I run the loop. Despite verifying that the UUID is inserted in the collection.

Any Ideas ?

// Arrays from Mysql

ARRAY TO COLLECTION($colgroup;$GroupMysqlID;"MySQLGroupID";$GroupName_at;"Name";$GroupsUUID;"UUID")


For ($i;1;Size of array($GroupMysqlID))
	$sel:=ds.DjFields.query("MySQLGroupID = :1";$GroupMysqlID{$i})  // check if we have existing
	If ($sel.length=1)
		OB SET($colgroup[$i-1];"UUID";$sel.UUID) // add Primary key
		  // do nothing new record
	End if 
End for 

$compupdated:=ds.DjFields.fromCollection($colgroup)  // Update

Trace through and you will see your failure.

trace again.

Still not?

trace slowly and check content of $sel.UUID


Thats an entity selection, not an entity…

It was just luck that I saw that, but should be obvious then you trace through and check content

Thanks, I have been tracing for an hour or so :frowning:
Still in current record mind set.