I couldn't seem to get Selection To JSON with a template to do what I wanted
to. I ended up writing this and it fits the bill.
For each ($oRec;$oRecs)
$oComplex:=New object
$oComplex.key:=$oRec.ID
$oComplex.label:=$oRec.Name
$oComplex.open:=True
ARRAY OBJECT($aoFacilities;0)
$oFacilities:=$oRecs.Facilities
For each ($oFac;$oFacilities)
C_OBJECT($oChild)
$oChild:=New object
$oChild.key:=$oFac.ID
$oChild.label:=$oFac.Name
APPEND TO ARRAY($aoFacilities;$oChild)
End for each
OB SET ARRAY($oComplex;"children";$aoFacilities)
APPEND TO ARRAY($aoComplexs;$oComplex)
End for each
$vtReturn:=JSON Stringify array($aoComplexs)
Thanks
Justin Will
**********************************************************************
4D Internet Users Group (4D iNUG)
Archive: http://lists.4d.com/archives.html
Options: https://lists.4d.com/mailman/options/4d_tech
Unsub: mailto:[email protected]
**********************************************************************