locked
Party List - Alternate Key RRS feed

  • Question

  • Hi Community,

    In the following example I'm creating an email record on CRM Online 2016 (trial) where its from attribute references to an existing account by guid:

    // Create a new EntityCollection to add the party
    EntityCollection from = new EntityCollection();
    
    // Create activity party linked to account (from)
    Entity apEntity = new Entity("activityparty");
    apEntity.Attributes["partyid"] = new EntityReference("account", new Guid("475B158C-541C-E511-80D3-3863BB347BA8"));
    from.Entities.Add(apEntity);
    
    // Create email
    Entity emailEntity = new Entity("email");
    emailEntity.Attributes["subject"] = "Mail Subject GUID";
    emailEntity.Attributes["from"] = from;


    However, if account is referenced by existing alternate key (accountnumber) instead, it’s not able to reach corresponding account (Account With Id = 00000000-0000-0000-0000-000000000000 Does Not Exist):

    // Create a new EntityCollection to add the party
    EntityCollection from = new EntityCollection();
    
    // Create activity party linked to account (from)
    Entity apEntity = new Entity("activityparty");
    apEntity.Attributes["partyid"] = new EntityReference("account", "accountnumber", "AF3HN2S4");
    from.Entities.Add(apEntity);
    
    // Create email
    Entity emailEntity = new Entity("email");
    emailEntity.Attributes["subject"] = "Mail Subject AK";
    emailEntity.Attributes["from"] = from;


    In both cases, creation’s request is performed using same source code:

     

    CreateRequest createRequest = new CreateRequest();
    createRequest.Target = emailEntity;
    organizationService.Execute(createRequest);

    I'm not receiving this error if account is directly referenced, I mean, it's not indicated inside an attribute from an activityparty entity.<o:p></o:p>

    Could you please let me know if I’m missing some item on this action?

     

    Thanks in advance,

    Regards.

    Thursday, July 21, 2016 9:35 AM