locked
to find address in CRM dynamic 2011 using early bind (urgent) RRS feed

  • Question

  • hi,

    I need to create address in relation to ACCOUNT but after checking if the address exists, for this I want to create the ADDRESS entity but it does exists , it may that I am unable to find the way to find that. and if it exists then make the association with the account and if not then firstly create the address and then create the association.

    please send me some link so that I can understand the logic.

    thanks

    Saturday, August 31, 2013 12:21 PM

All replies

  • Hi,

    Are you trying to do this on the server (plugin/workflow) or on the client (Javascript or Silverlight?)

    Scott


    Scott Durow
    Blog www.develop1.net    Follow Me
    Rockstar365
    If this post answers your question, please click "Mark As Answer" on the post and "Mark as Helpful"

    Saturday, August 31, 2013 8:44 PM
    Answerer
  • Hi ,

    Thanks for your reply..

    I am creating  a windows service which will fetch data from a data base and then it will populate the Dynamic CRM and it will run on server. For this I have created the Early bond class of the Organization Service but unable to create the Address entity as like Account. and I have checked from the UI of CRM the address and the Account have association (1:N) or other Now question is firstly I want to check whether the address exists in CRM if yes then create the association if not then firstly create the Address and then create the Association..

    like this I have to create Contract also... please send me some link ... i have tried the MSDN but unable to find any thing.

    Its Urgent

    Thanks

    Sunday, September 1, 2013 4:25 AM
  • Hi,

    To find the addresses for an account:

    using (var context = new OrganizationServiceContext(service))
    {
        // Find Address
        var existingAddresses = from a in context.CreateQuery<CustomerAddress>()
                              where a.ParentId.Id == accountid
                              select a;
    
    
    }

    To create a new Address:

    // Create address
    var newAddress = new CustomerAddress
    {
        ParentId = new CrmEntityReference(Account.EntityLogicalName,accountid),
        Line1 = "line1"
    };
    
    service.Create(newAddress);
    

    You can read more in the SDK sample:http://msdn.microsoft.com/en-us/library/gg509028.aspx. This sample shows creating and searching for records.

    hth,

    Scott


    Scott Durow
    Blog www.develop1.net    Follow Me
    Rockstar365
    If this post answers your question, please click "Mark As Answer" on the post and "Mark as Helpful"

    Sunday, September 1, 2013 10:07 AM
    Answerer