KNOWLEDGE BASE
Log In    |    Knowledge Base    |    4D Home
Tech Tip: Converting entity selections to collections before passing to new process
PRODUCT: 4D | VERSION: 17 | PLATFORM: Mac & Win
Published On: May 22, 2019

Entity selections cannot be successfully passed as arguments in the New process as it results in a Null object received by the new process as shown below.

C_LONGINT($pid)
C_OBJECT($peopleSelection)

$peopleSelection:=ds.People.all()
$pid:=New process("testMethod";0;"Process A";$peopleSelection)




Instead, convert the entity selection to a collection using entitySelection.toCollection() when passing as an argment to another process and convert it back to an entity selection using dataClass.fromCollection().

C_LONGINT($pid)
C_OBJECT($peopleSelection)
$peopleSelection:=ds.People.all()
$pid:=New process("testMethod";0;"Process A";$peopleSelection.toCollection())




Note: One aspect to note regarding dataClass.fromCollection() is that the command writes back to the data store. In other words, make sure the entities within the collection are unlocked before this command is called. Otherwise, you may encounter a runtime error regarding that an entity could not be saved.