locked
How to know whether a given account is the top most parent account in a heirarchy of sub accounts? RRS feed

  • Question

  • Hi,

    I need to find out the top most parent account in a given hierarchy of accounts. The parentaccountid for the top most account will be null so I tried entity.Contains("parentaccountid") but it always returns true for parent and child accounts.

    I then tried entity.Attributes.Contains("parentaccountid") but it threw an exception.

    Is there any way to know parent account.? 


    Thanks Vineet

    Thursday, May 14, 2015 6:03 PM

All replies

  • Where are you trying to find this?  JavaScript? C# Plugin?
    Thursday, May 14, 2015 7:09 PM
  • inside a plugin

    Thanks Vineet

    Friday, May 15, 2015 1:54 AM

  • I then tried entity.Attributes.Contains("parentaccountid") but it threw an exception.


    the Contains method returns true or false, it can't throw an exception, so the problem is somewhere else in your code. Post your plugin code

    My blog: www.crmanswers.net - Rockstar 365 Profile

    Friday, May 15, 2015 3:46 AM
  • Hi,

    Is this plugin for a Deleterequest?

    Thanks

    Friday, May 15, 2015 4:39 AM
  • Have you tried to test if parentaccounted == null instead?
    Friday, May 15, 2015 10:05 AM
  • How are you instantiating the entity instance in code ? If it is the Target InputParameter, then it will only be populated if it has changed. To get the current value, use an EntityImage, and test parentaccountid in that

    Microsoft CRM MVP - http://mscrmuk.blogspot.com/ http://www.excitation.co.uk

    Friday, May 15, 2015 11:34 AM
    Moderator