Tech Tip: Avoid Shared Group Error 10724
PRODUCT: 4D | VERSION: 21 | PLATFORM: Mac & Win
Published On: April 13, 2026
This error occur when a shared object that already belongs to one group is assigned to a different shared group object/collection.
Code example:
Solution:
Test method:
Code example:
property items : Collection property index : Object shared singleton Class constructor() This.items:=New shared collection This.index:=New shared object // --- This will FAIL with error -10724 --- shared Function registerItem($item : Object) Use (This) This.items.push($item) This.index[$item.itemId]:=$item End Use shared Function getItem($itemId : Text) : Object return This.index[$itemId] |
Solution:
| shared Function registerItem($item : Object) var $safeCopy : Object $safeCopy:=OB Copy($item; ck shared) Use (This) This.items.push($safeCopy) This.index[$safeCopy.itemId]:=$safeCopy End use |
Test method:
| var $requestItem : Object var $item : Object $requestItem:=New shared object("requestId"; "REQ-001") $item:=New shared object("itemId"; "U097"; "code"; "xyz987") Use ($requestItem) $requestItem.item:=$item End use cs.Item.me.registerItem($item) var $result : Object $result:=cs.Item.me.getItem("U097") ALERT("Item: "+$result.code) |