How do I get a top level group ID? I have a group thats nested a few layers down, when I access the ParentGroupId, it just returns one level up. Whats the best way to get the "root" group, or the most top group?
How do I get a top level group ID? I have a group thats nested a few layers down, when I access the ParentGroupId, it just returns one level up. Whats the best way to get the "root" group, or the most top group?
Figured it out. Code below if anyone else runs into this:
var groupParentId = group.ParentGroupId; var parentGroup = null; while(groupParentId != -1 && groupParentId != 1){ parentGroup = core_v2_group.Get({Id: groupParentId}); groupParentId = parentGroup.ParentGroupId; if(parentGroup.Id == 227){ matchingId = true; } }
Figured it out. Code below if anyone else runs into this:
var groupParentId = group.ParentGroupId; var parentGroup = null; while(groupParentId != -1 && groupParentId != 1){ parentGroup = core_v2_group.Get({Id: groupParentId}); groupParentId = parentGroup.ParentGroupId; if(parentGroup.Id == 227){ matchingId = true; } }
The top level grouip is always the root group. $core_v2_group.Root.Id
core_v2_group Script API