Tech Tip: Converting entity selections to collections before passing to new process
PRODUCT: 4D | VERSION: 17 | PLATFORM: Mac & Win
Published On: May 22, 2019
Your current browser may not allow you to download the asset. We recommend Mozilla Firefox or Google Chrome.
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.
$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().
$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.