web
You’re offline. This is a read only version of the page.
close
Skip to main content
Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

How to create a entity record with a "partylist" data type field, through c# code?

(0) ShareShare
ReportReport
Posted on by

How to create a entity record with a "partylist" data type field, through c# code?

i have a entity which has the "to" field of type party list, how do i create the record? through code

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    Rawish Kumar Profile Picture
    13,758 on at
    RE: How to create a entity record with a "partylist" data type field, through c# code?

    Hi Rahul,

    Please use below post : stackoverflow.com/.../create-activityparty-in-crm-without-early-bound-entities

  • Suggested answer
    a33ik Profile Picture
    84,331 Most Valuable Professional on at
    RE: How to create a entity record with a "partylist" data type field, through c# code?

    Hello,

    Check following - www.magnetismsolutions.com/.../working-with-dynamics-crm-activity-party-lists-in-c--plugins

  • Suggested answer
    Arpit Shrivastava Profile Picture
    7,518 User Group Leader on at
    RE: How to create a entity record with a "partylist" data type field, through c# code?

    Hello,

    Try below code snippet:

    Entity partyListEntity= new Entity();

    partyListEntity= new Entity("activityparty");

    partyListEntity["partyid"] = new EntityReference("systemuser", new Guid("CE08EE7F-4F36-E111-B6F6-0050569838D6"));

    or

    partyListEntity["addressused"] = "arpit.crmconsultant@gmail.com";
    Entity[] aryTo = { partyListEntity};
    emailCreate["to"] = aryTo;

    Mark this is an answer If it helps.

     

    Cheers
    Arpit
    https://arpitmscrmhunt.blogspot.in

  • Community Member Profile Picture
    on at
    RE: How to create a entity record with a "partylist" data type field, through c# code?

    Hi Guys, 

    thanks for your help, my requirement is like this -

    I have to retrieve a record from CRM, which contains few fields with data type "partylist", ex:- "to"

    I am able to retrieve them as an EntityCollection

    Now i have to create another record and set the "to" field to the value retrieved in the step above

    any suggestions?

  • Suggested answer
    Arpit Shrivastava Profile Picture
    7,518 User Group Leader on at
    RE: How to create a entity record with a "partylist" data type field, through c# code?

    Hi Rahul,

    Please have a look below code for the reference.

    Apologies in advance for any syntax or build error, I have not tested it. But logic would be the same.


    EntityCollection toCollection = (EntityCollection)sourcentityObj["to"];
    if (toCollection != null && toCollection.Entities.Count > 0)
    {
    // get value of 'TO' field from source entity
    Entity toParty = toCollection[0]; //activityparty entity
    EntityReference toRef = (EntityReference)toParty["partyid"]; //actual entity ref

    // set value of 'TO' field in destination entity
    Entity partyListEntity= new Entity();

    partyListEntity = new Entity("activityparty");

    partyListEntity["partyid"] = toRef;

    Entity[] aryTo = { partyListEntity};

    partyListEntity["to"] = aryTo;
    }


    or

     

    EntityCollection Recipients = sourcentityObj.GetAttributeValue<EntityCollection>("to");

    foreach (var party in Recipients.Entities)
    {

    // get value of 'TO' field from source entity
    var partyName = party.GetAttributeValue<EntityReference>("partyid").LogicalName;

    var partyId = party.GetAttributeValue<EntityReference>("partyid").Id;

    // set value of 'TO' field in destination entity
    Entity partyListEntity= new Entity();

    partyListEntity= new Entity("activityparty");

    partyListEntity["partyid"] = new EntityReference(partyName, partyId);

    Entity[] aryTo = { partyListEntity};

    partyListEntity["to"] = aryTo;

    }

    If found useful, please mark the answer as verified.

    Cheers
    Arpit
    https://arpitmscrmhunt.blogspot.com

     

     

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Abhilash Warrier – Community Spotlight

We are honored to recognize Abhilash Warrier as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
HR-09070029-0 Profile Picture

HR-09070029-0 2

#2
ED-30091530-0 Profile Picture

ED-30091530-0 1

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans