In Dynamics 365, an activity (phonecall, task, email, appointment) can either be associated with a single person or a group of person which represent the Activity Party. An activity can have multiple activity parties.
For Example, an email can either be sent to CRM Contacts or CRM User or Queue. So there must be such type of field available in CRM which can refer to multiple entities as Lookup can only be associated to only single entity. Hence Party List comes into picture.
When you add any Party List type of field on the CRM form, you may notice that these fields look like Lookup fields but may function a little different. For example the Email\’s From and To fields let you select multiple records of the same or different type.
- CRM Activity Party List field is a special type of lookup field which refers to multiple entities. To hold or store these multiple entities references, Microsoft has provided one special type of entity named Activity Party.
- Activity Party, has one special field called Party Id. which has the capability to store multiple entities references like user, contact, account, lead etc.
- Hence, if we have to get/set value in Party List Field, we have to interact with Activity Party Party Id field.
- So, we just have to remember, while getting or setting value in party list fields (to, from cc, bcc, regarding etc). We have to use Activity Party Entity and Party Id field. We can understand it better through code also.
Get value from Party List Fields using C#
public static void Main(string[] args)
{
// Pass the email record guid
getPartyList(\"C4723A9F-592F-E911-A979-000D3AF24324\");
}
public static void getPartyList(string emailRecordId)
{
// Retrieve email record
//Here service is your IOrganisation Service Object
Entity email =
service.Retrieve(\"email\",new Guid(emailRecordId),new ColumnSet(\"from\", \"to\"));
// get value from partylist - \'FROM\' field
EntityCollection from = email.GetAttributeValue<EntityCollection>(\"from\"); if (from != null && from.Entities.Count > 0) { foreach (var item in from.Entities) {
EntityReference partyId = item.GetAttributeValue<EntityReference>(\"partyid\");
string addressUsed = item.GetAttributeValue<string>(\"addressused\");
Console.WriteLine(\"Email Send From: \" + partyId.Name + \",\" + addressUsed);
}}
Console.WriteLine(\"------------------------------------------------------------------\");
// get value from partylist - \'TO\' field
EntityCollection to = email.GetAttributeValue<EntityCollection>(\"to\"); if (to != null && to.Entities.Count > 0) { foreach (var item in to.Entities) { EntityReference partyId = item.GetAttributeValue<EntityReference>(\"partyid\"); string addressUsed = item.GetAttributeValue<string>(\"addressused\"); Console.WriteLine(\"Email Send To: \" + partyId.Name + \",\" + addressUsed); } } Console.ReadKey();
}
Output
Set value in Party List Fields using C# (Single Recipient)
public static void Main(string[] args)
{// call the function in Main
SetPartyList_SingleRecipient();
}public static void SetPartyList_SingleRecipient()
{
// declare party list entity to set value in FROM field
Entity from = new Entity(\"activityparty\");
// declare party list entity to set value in TO field
Entity to = new Entity(\"activityparty\");
// set value in FROM field
from[\"partyid\"] =new EntityReference(\"systemuser\", new Guid(\"D72D8D9E-FCEC-4C6B-8340-A2CB9FAA88D5\"));
// set value in TO field
to[\"partyid\"] =new EntityReference(\"account\", new Guid(\"475B158C-541C-E511-80D3-3863BB347BA8\"));
// declare party list entity to set value in FROM field
Entity email = new Entity(\"email\");
// insert value in email FROM field
email[\"from\"] = new Entity[] { from };
// insert value in email TO field
email[\"to\"] = new Entity[] { to };
//Set regarding object property (i.e. The entity record, which u want this email associated with)
EntityReference regardingObject =new EntityReference(\"contact\", new Guid(\"49A0E5B9-88DF-E311-B8E5-6C3BE5A8B200\"));
email.Attributes.Add(\"regardingobjectid\", regardingObject);
//Set subject & body properties
email.Attributes.Add(\"subject\", \"Email created from Console for Single recipients\");
email.Attributes.Add(\"description\", \"Email created from Console for Single recipients\");
//Create email activity//Here service is your IOrganisation Service Object
Guid emailID = service.Create(email); Console.WriteLine(\"Email created successfully\"); Console.Read();
}Output
Set value in Party List Fields using C# (Multiple Recipient)
public static void Main(string[] args)
{// call the function in Main
SetPartyList_MutipleRecipient();
}public static void SetPartyList_MutipleRecipient()
{
// set value in FROM party list field
Entity from1 = new Entity(\"activityparty\");
// two accounts inside the TO field
Entity to1 = new Entity(\"activityparty\");
Entity to2 = new Entity(\"activityparty\");
// two contacts inside the TO field
Entity to3 = new Entity(\"activityparty\");
Entity to4 = new Entity(\"activityparty\");
// set value in FROM field
from1[\"partyid\"] =new EntityReference(\"systemuser\", new Guid(\"D72D8D9E-FCEC-4C6B-8340-A2CB9FAA88D5\"));
// set multiple values in TO field
to1[\"partyid\"] =new EntityReference(\"account\", new Guid(\"475B158C-541C-E511-80D3-3863BB347BA8\"));
to2[\"partyid\"] =new EntityReference(\"account\", new Guid(\"A8A19CDD-88DF-E311-B8E5-6C3BE5A8B200\"));
to3[\"partyid\"] =new EntityReference(\"contact\", new Guid(\"25A17064-1AE7-E611-80F4-E0071B661F01\"));
to4[\"partyid\"] =new EntityReference(\"contact\", new Guid(\"49A0E5B9-88DF-E311-B8E5-6C3BE5A8B200\"));Entity email = new Entity(\"email\");
//Set regarding object property (i.e. The entity record, which u want this email associated with)
EntityReference regardingObject =new EntityReference(\"contact\", new Guid(\"49A0E5B9-88DF-E311-B8E5-6C3BE5A8B200\"));
email.Attributes.Add(\"regardingobjectid\", regardingObject);
// Insert value in FROM field
email[\"from\"] = new Entity[] { from1 };
// Insert value in TO field
email[\"to\"] = new Entity[] { to1, to2, to3, to4 };
//Set subject & body properties
email.Attributes.Add(\"subject\", \"Email created from Console for Multiple recipients\");
email.Attributes.Add(\"description\", \"Email created from Console or Multiple recipients\");
//Create email activity//Here service is your IOrganisation Service Object
Guid emailID = service.Create(email); Console.WriteLine(\"Email created successfully\"); Console.Read();
}Output
In the above code,To get the value from Party List TO and FROM fields:
We are retrieving the value from Party Id field of Activity Party entity, which holds the record’s Guids which was selected in Email’s FROM and TO fields.To set the value in Party List TO and FROM fields:
We are first passing the value in Party Id field of Activity Party entity and then setting it’s Entity reference to partylist FROM and TO fields.
Note:
- For demonstration, I have hard-coded the record Guids. However, in real time you\’ll have to pick these values dynamically based upon your requirement.
- For demonstration, I have taken the example of Email Activity Entity and it\’s To and From party list fields. Same code/logic can also be used for other activities and party list fields.
Hi Arpit,Can you please elaborate more about the 'From' field in your next post, as it has few restriction compared to other partylist type fields.Thanks,Amit Kumar Rath
LikeLike
Very good content. I read your blog that was awesome, please doing continue daily post. Customer Relations Software in Indore
LikeLike
this is the best softwre you can do this foe small business B2B Lead Generation Software. this software for handle online accounting
LikeLike
This comment has been removed by the author.
LikeLike
Very interesting,good job and thanks for sharing such a good blog.your article is so convincing that I never stop myself to say something about it.You’re doing a great job.Keep it up, For Microsoft Dynamics 365 services contact Dynamics Square.
LikeLike
Very nice site. I came across this on Google, and I am stoked that I did. I will definitely be coming back here more often. Wish I could add to the conversation and bring a bit more to the table, but am just taking in as much info as I can at the moment. I am an CRM developer, I recently work on web based CRM software. Thanks for sharing such great content.
LikeLike
Hello, Thank you for this excellently put together blog. It is very clear and helpful.How do you update an existing From field on email? The reason is I'm working on a case management solution in CRM and I've got the case creation rules set to not create a contact for emails where the contact does not already exist.For emails from unknown sources I'd like to be able to run a dialog on selected emails and 'escalate them to contact+case'. This will create a contact with the email field being taken from the sender's email and then my dialog creates a case and sets the regarding field on the original email to be the new case.This is all good except the 'From' field on the original email is still showing as 'unresolved' id.e. the address used is still showing the email in red in the from field and not the newly created contact. I'm trying to write a plugin which sets the from field to the newly created contact but it's not updating.Do I need to create a new email and delete the old email or can I update the old email's from field?Thank you,Mohamed
LikeLike
Nice Article. We are Software Solution Providers in Islamabad, working with international clients in creating, designing and managing their websites and customer relations/Sales etc.We Provide: 1.) SEO and Digital Marketing Services 2.) Web Design and Development Services 3.) CRM and ERP systems
LikeLike
This comment has been removed by the author.
LikeLike
Great blog learned many things about Crm Software from this article, very informative .CRM system is the software that you and your company need to automate the processes and activities associated with customer relationship management. For many years, the locally hosted CRM solutions have widely been used by large corporations and medium-sized businesses. Today, you have a chance to implement the CRM systems, too. Likewise, you have a possibility to choose between the locally hosted and web based CRM solutions. The only way to make the right choice is to learn more about the different types of CRM systems.Best Crm Software for Small Businesscrm systems for small businessesbest business management softwareClient Management Software for Small Business Customer Relation Management Software Customer Management Software Small Business Dropshipping Software
LikeLike
This comment has been removed by a blog administrator.
LikeLike
Hello there! This is my first comment here, so I just wanted to give a quick shout out and say I genuinely enjoy reading your articles. Can you recommend any other blogs/websites/forums that deal with the same subjects? Thanks.Surya Informatics
LikeLike
This comment has been removed by a blog administrator.
LikeLike
This comment has been removed by a blog administrator.
LikeLike
Thank you for this excellently put together blog. It is very clear and helpful. If you are in a business and want to get a highly professional and effective customer relationship management solution to make a strong client base there are a number of expert services whom you can look up to get the best solutions. Choose them wisely and get the best benefits of this best business management software system with their help.crm systems for small businesses|Client Management Software For Small Business|Customer Relation Management Software
LikeLike
Very informative blog about CRM. Thanks for enhancing our knowledge about CRM. Are you looking to improve customer satisfaction levels through our Microsoft Dynamics CRM? Talk to our CRM experts to know what features you can use to make your CRM process more efficient and ultimately boost your productivity.
LikeLike
This comment has been removed by a blog administrator.
LikeLike
This comment has been removed by a blog administrator.
LikeLike
Thanks for sharing an informative post, If you wants to know about CRM system This is the right place for you.
LikeLike
It’s a wonderful blog you shared here, I read the whole content and found it so easy to understand in language and is also full of amazing and useful information. Thanks a lot for sharing it.Restaurant Online Ordering app
LikeLike
This was actually what i was looking for,and i am glad to came here you keep up the fantastic work!my weblog.. I like the trend that content is becoming more and more important.CRM Software In IndiaCRM Software In ChennaiCRM Software In Bangalore
LikeLike
Good articles, Have you heard of LFDS (Le_Meridian Funding Service, Email: lfdsloans@outlook.com –WhatsApp Contact:+1-9893943740–lfdsloans@lemeridianfds.com) is as USA/UK funding service they grant me loan of $95,000.00 to launch my business and I have been paying them annually for two years now and I still have 2 years left although I enjoy working with them because they are genuine Loan lender who can give you any kind of loan.
LikeLike
This comment has been removed by the author.
LikeLike
Nice Blog With Full of Knowledge Thanks For Sharing..ServiceNow Training in Hyderabad ServiceNow Training in AmeerpetServiceNow TrainingServiceNow Online Training
LikeLike
This comment has been removed by a blog administrator.
LikeLike
This comment has been removed by a blog administrator.
LikeLike
Great post.It seems to be interesting and gave me lot of information,Thank for sharing it.I am looking forward for new articles.keep it up.Website Development Company in Bangalore | Website Design Company in Bangalore | Mobile App Development Companies in Bangalore | Game Development Companies in Bangalore
LikeLike
Great post with unique information.This blog will really helpful for me to develop my skills in a right way.Thanks for sharing,keep update with your blogs. Website Design Company in Bangalore | Mobile App Development Companies in Bangalore | Website Development Company in Bangalore
LikeLike
Thanks for Sharing This Article.It is very so much valuable content. I hope these Commenting lists will help to my websiteservicenow online trainingbest servicenow online traiingtop servicenow online training
LikeLike
Thanks for sharing such a great blog Keep posting.CRM softwareCRM softwareonline CRM softwarecrm software
LikeLike
This comment has been removed by a blog administrator.
LikeLike
This comment has been removed by a blog administrator.
LikeLike
I just loved your article on the beginners guide to starting a blog.If somebody take this blog article seriously in their life, he/she can earn his living by doing blogging.thank you for thizs article. servicenow online training , best pega online training ,top servicenow online training .
LikeLike
Thanks, this is generally helpful.Still, I followed step-by-step your method in this salesforce cpq traininglearn salesforce cpq
LikeLike
Really appreciate you sharing this article post. Happy Valentines Day Much thanks again. Awesome.
LikeLike
It's interesting that many of the bloggers to helped clarify a few things for me as well as giving.Most of ideas can be nice content.The people to give them a good shake to get your point and across the command.Best CRM System
LikeLike
Thank you for sharing the valuable information. servicenow trainingservicenow certification
LikeLike
Im no expert, but I believe you just made an excellent point. You certainly fully understand what youre speaking about, and I can truly get behind that. Shisha Hire London
LikeLike
Why do only so much written on this subject? Here you see more. Shisha Hire
LikeLike
This is most informative and also this post most user-friendly and super navigation to all posts.3d Laser Scanning Services in BirminghamDimension Control services in Bayern Germany
LikeLike
Special thanks to (hackingsetting50@gmail.com) for exposing my cheating husband. Right with me i got a lot of evidences and proofs that shows that my husband is a fuck boy and as well a cheater ranging from his text messages, call logs, whats-app messages, deleted messages and many more, All thanks to (hackingsetting50@gmail.com), if not for him i will never know what has been going on for a long time. Contact him now and thank me later.
LikeLike
How do I set an email address to a to field as party list. The email address is unresolved and respective contact doesn't exist.
LikeLike