locked
How to get all sub-accounts as a parent account? RRS feed

  • Question

  • Hello,

    I want to have a list of all sub-accounts from a parent account via CrmService. How should I do?

    thanks in advance

    Monday, April 12, 2010 8:55 AM

Answers

  • Try this:

     

    QueryByAttribute qbe = new QueryByAttribute();
    
    qbe.EntityName = "account";
    
    qbe.attributes = new string[]{"parentaccountid"};
    
    qbe.values = new object[]{ThePArentAccountGuid};
    
    qbe.ColumnSet = new AllColumns();
    
    BusinessEntityCollection bec = service.RetrieveMultiple(qbe);

     


    My blog : http://mscrmtools.blogspot.com
    You will find:
    Bulk Delete Launcher View Layout replicator
    ISV.Config Manager Form Javascript Manager
    Assembly Recovery And others (use tool tag on my blog)
    Monday, April 12, 2010 9:02 AM
    Moderator

All replies

  • Try this:

     

    QueryByAttribute qbe = new QueryByAttribute();
    
    qbe.EntityName = "account";
    
    qbe.attributes = new string[]{"parentaccountid"};
    
    qbe.values = new object[]{ThePArentAccountGuid};
    
    qbe.ColumnSet = new AllColumns();
    
    BusinessEntityCollection bec = service.RetrieveMultiple(qbe);

     


    My blog : http://mscrmtools.blogspot.com
    You will find:
    Bulk Delete Launcher View Layout replicator
    ISV.Config Manager Form Javascript Manager
    Assembly Recovery And others (use tool tag on my blog)
    Monday, April 12, 2010 9:02 AM
    Moderator
  • Thanks for your reply. But I don't think your code is what I need.

    I have the parent account guidId, and try to find all of its sub-accounts.

    I know how to find out a sub-accout's parent account, but not the other way round.

    Any suggestions? Many thanks.

    Monday, April 12, 2010 9:37 AM
  • IT IS THE GOOD CODE!!!

    it does what you ask...


    My blog : http://mscrmtools.blogspot.com
    You will find:
    Bulk Delete LauncherView Layout replicator
    ISV.Config Manager Form Javascript Manager
    Assembly RecoveryAnd others (use tool tag on my blog)
    Monday, April 12, 2010 9:45 AM
    Moderator
  • IT IS THE GOOD CODE!!!

    it does what you ask...


    My blog : http://mscrmtools.blogspot.com
    You will find:
    Bulk Delete Launcher View Layout replicator
    ISV.Config Manager Form Javascript Manager
    Assembly Recovery And others (use tool tag on my blog)
    Take it easy, Tanguy. Just don't answer to this visitor ;)

    Truth is opened the prepared mind

    My blog (english)
    Мой блог (русскоязычный)
    Monday, April 12, 2010 2:17 PM
    Moderator
  • Hi dev_secon,

    Everyone here is trying to be helpful, we all do it for free as our personal effort to help each other, and more importantly it's a community where we learn from each other. So it would be nice that you can give a little more respect to the effort.

    Actually I can confirm that Tanguy's code is what you are looking for, unless your requirement statement was wrong at first place.

    Let us know if you need any further assistance. Don't get it personal, Andriy is a very respectful MVP here. He is always very helpful as well.

    Cheers,


    Daniel Cai | http://danielcai.blogspot.com
    Monday, April 12, 2010 3:00 PM
  • Sorry, it was just the most amazing answer I already received on the CRM forums...

    I'll be cool, I promise :)


    My blog : http://mscrmtools.blogspot.com
    You will find:
    Bulk Delete LauncherView Layout replicator
    ISV.Config Manager Form Javascript Manager
    Assembly RecoveryAnd others (use tool tag on my blog)
    Monday, April 12, 2010 3:02 PM
    Moderator
  • Cool, let's all be cool. ;)

    Have a wonderful day.


    Daniel Cai | http://danielcai.blogspot.com
    Monday, April 12, 2010 3:08 PM