locked
Having trouble changing the account associated with a contact RRS feed

  • Question

  • In a script task of an SSIS package I am trying to set the account related to a contact entity. I am also setting a number of other attribute values, and those all seem to work, but the account is not being updated.

    One of my difficulties is finding out exactly what the field names should be in the code. How do I know what the "correct" attribute name should be? It's simply a key-value pair so intellisense isn't any help, and I haven't  yet found a good online reference.

    Here's the code:

    // row.<attribute>changedflag is just a column in the ssis pipeline indicating if the incoming value is different from the current CRM value
    
    Microsoft.Xrm.Sdk.Entity contact = new Microsoft.Xrm.Sdk.Entity("contact");
    contact.Id = Row.contactid;
    
    // a bunch like this, which all work fine:
    if (!Row.firstname_IsNull && Row.firstnamechangedflag) { contact["firstname"] = Row.firstname; }
    if (!Row.lastname_IsNull && Row.lastnamechangedflag) { contact["lastname"] = Row.lastname; }
    // etc...
    
    // I've tried these two methods to try to set the associated account
    // None of them seem to work. The account stays as null in the filteredaccount view
    //if (!Row.accountid_IsNull && Row.accountidchangedflag) { contact["accountid"] = new Microsoft.Xrm.Sdk.EntityReference("account", (Guid)Row.accountid); }
    //if (!Row.accountid_IsNull && Row.accountidchangedflag) { contact["accountid"] = Row.accountid; }
    
    
    svc.Update(contact);

    Wednesday, July 8, 2015 6:03 AM