Retrieve accountid from name field value RRS feed

  • Question

  • CRM2016

    I am having a brain freeze!

    I'm writing a plugin (vb |) to add a new record to a child entity. I need to get the accountid for the lookup based on the account.name field

    can someone point me in the right direction

    Dont ask me .. i dont know

    Tuesday, November 22, 2016 2:07 PM

All replies

  • Hello,

    Here is code you can use (but you will have to convert it from C# to VB:

                var query = new QueryByAttribute("account")
                    ColumnSet = new ColumnSet(false)
                query.AddAttributeValue("name", "put your account name here");
                var account = service.RetrieveMultiple(query).Entities.FirstOrDefault();

    Dynamics CRM MVP
    Read My blog
    Subscribe for one of my courses

    Tuesday, November 22, 2016 2:23 PM