I have distincts Users (login user) , and have permisions to see only a few locations or branchs, as show the image…
the problem is this 
i can’t get the Locatios for this user only as the picture showed. can anyone help me with this.???
i need only get the branch, and the 3 locations. only … using the API.
Hello. The way to get the exact same data as seen when UI, with the least amount of code is to a TreeView object as follows -
Dim currentUser As AvontusUser = AvontusUser.GetUser(userName Or userID);
TreeView tvOrganization = new TreeView();
StockingLocationOrganization orgTree = StockingLocationOrganization.GetOrganization(ActiveStatus.Active)
orgTree.BuildTreeView(tvOrganization, OrgViewGrouping.ByJob, JobTreeNodeDisplayType.Name, currentUser.RelatedID, currentUser.UserID,
currentUser.PrimaryTradingPartnerID)
TreeNode oMainNode = tvOrganization.Nodes[0];
PrintNodesRecursive(oMainNode);
public void PrintNodesRecursive(TreeNode oParentNode)
{
Console.WriteLine(oParentNode.Text);
Console.WriteLine(GetStockingLocationID(oParentNode));
foreach(TreeNode oSubNode in oParentNode.Nodes)
{
PrintNodesRecursive(oSubNode);
}
}
public Guid GetStockingLocationID(TreeNode Node)
{
if ((StockingLocationOrganization.GetPartnerType(Node) == PartnerTypes.Customer)) {
return Guid.Empty;
}
NodeTag tag = ((NodeTag)(Node.Tag));
return tag.StockingLocationID;
}
1 Like
Oki , i will try on this!! and will keep u updated!! y will do on C# code!! Thanks!
cant unflag this post … can u do?
THANKS!!! works Fine for me!!!
thanks a Lot of lots!!!

Great, glad that works. You’re very welcome!
1 Like