· Sep 26, 2016 2m read

Tips & Tricks - Export object to global

We're developing Ensemble PoC and one day our frontend developer (who doesn't have Ensemble production running) said that Populate just doesn't cut it and he needs to see the real data. He needed only one object, but the problem was - it's a big object. Still, I checked ids of everything related and wrote this command (parts omitted, but you get the idea):


Well, later it turns out that more than one object is needed, and I had most certainly not enjoyed traversing references manually, so I wrote the utility to export objects (underlying globals really) to XML. Check it out on GitHub. I won't post all the code, but here are some interesting snippets.


Get data global for an active class storage strategy:

ClassMethod getDataGlobal(class As %String) As %String
    set strategy = $$$comClassKeyGet(class, $$$cCLASSstoragestrategy)
    return $$$defMemberKeyGet(class, $$$cCLASSstorage, strategy, $$$cSDEFdatalocation)

Get list of children/many objects ids for parentId (copied from %RelationshipObject:Load):

/// class - property type, property - INVERSE property name, parentId - id, for which we constrict list of id
ClassMethod getManyForOne(class As %String, property As %String, parentId As %Integer) As %List
    set sc=$classmethod(class, property _ "RExec", .handle, parentId)
    set children = ""
    for {
        set sc=$classmethod(class, property _ "RFetch", .handle, , .ids, .returnCount, .atEnd)
        set children = children _ ids
    return children


Here's some points on how the code can be expanded:

  • Export streams
  • Search for property references to this object
  • Specify number of levels


Have you encountered the same problem? If so, how have you solved it?

Discussion (1)0
Log in or sign up to continue