CRM Dvelopment Series
Enable Entity Records for Dynamics 365 Partner Portals
Category: CRM Dvelopment Series,Dynamics 365,Dynamics 365 CE Online,Dynamics 365 Portals,Dynamics Portal,Partner Portal view,Partner Portals Author: HIMBAP Date: 2 weeks ago Comments: 0

Introduction If you are working with Partner Portal, you may notice that you are not able to see records in Portal even though you have all the required permission setup correctly. We are going to discuss another quick check that you can do while not getting data. Solution Most common reason when you are not able to see the data… Read more »
Source: Mahendra Pal


Filtering Lookup based on the link entity
Category: adding custom view to lookup Dynamics 365 CE,CRM Dvelopment Series,Dynamics 365,Dynamics 365 CE Online,Lookup filtering in Dynamics 365 CE,Using under in FetchXML Author: HIMBAP Date: 2 months ago Comments: 0

Introduction Recently we got one request to filter lookup based on the account as well as parent account of the account. This blog post is about how we implemented this requirement. Solution If we want to filter lookup based on the other lookup we can simply edit target field properties and can set Related Record Filtering option. We can select… Read more »
Source: Mahendra Pal


SharePoint integration for Work Order- Part 2
Category: Create SharePoint folder using Flow,CRM Dvelopment Series,Dynamics 365,Implement Folder Structure using Flow,Implementing hierarchical folder structure using Flow,Microsoft Flow,Setting up SharePoint integration for Work Order using Flow,SharePoint Integration for Dynamics 365 Author: HIMBAP Date: 4 months ago Comments: 0

Introduction Recently while working on Field Service project, we got requirement to setup SharePoint integration where customer wanted to use Folder stricture based on the Account entity. By default entity based folder structure is not supported for work order entity so we used Flow to implement this requirement. This is our second article, please check first article before reading this… Read more »
Source: Mahendra Pal


SharePoint integration for Work Order- Part 1
Category: Create SharePoint folder using Flow,CRM Dvelopment Series,Dynamics 365,Dynamics 365 CE Online,Implement Folder Structure using Flow,Implementing hierarchical folder structure using Flow,Microsoft Flow,Setting up SharePoint integration for Work Order using Flow,SharePoint Integration for Dynamics 365 Author: HIMBAP Date: 5 months ago Comments: 0

Introduction
Recently while working on Field Service project, we got requirement to setup SharePoint integration where customer wanted to use Folder stricture based on the Account entity. By default entity based folder structure is not supported for work order entity so we used Flow to implement this requirement, in this article we are going to discuss the same.
Requirement
Implement account entity folder structure for work order entity so that all the work order related documents is stored under parent customer folder hierarchy.
Solution
When I got this requirement, I thought it can be achieved using out of the box configuration but when I completed SharePoint integration setup and tested, I found , Dynamics 365 CE was not creating folder for work order entity under parent service account, instead it was creating work order folder under standalone work order document library. When I tried to upload document in child opportunity, it was creating opportunity folder correctly under parent account in SharePoint. When I was troubleshooting this issue, I found this KB Which explains why work order document is not create under account hierarchy because Work order entity have multiple N:1 relationship record with Account entity.

With the exception of the opportunity and contract entities, a hierarchical folder structure will not be automatically created in SharePoint for entities that have more than one many-to-one (N:1) relationship with the parent entity.

After identifying the issue, next step is to fix it with minimal efforts and Microsoft Flow came into my mind as I have used it earlier for SharePoint integration. let’s see how we can create Work Order structure under Account.

The whole Flow to create work order folder is divided into two parts, the first part is below where we added three steps:
1. First steps is to start flow when new work order record is created so we selected Create step from Dynamics 365 connector.
workorderflow2
2. Second steps is to Get Record step to get service account record because we need customer name to for SharePoint folder path.
workorderflow3_
3. There is no direct option to create folder in SharePoint but we can use Create File option from SharePoint connector where we can upload dummy file, and it will setup folder for us :)
workorderflow1

We have created SharePoint folder for work order under account it now, but Dynamics 365 CE SharePoint won’t use this folder unless we will setup Document Location record and that’s the tricky part. To create document library record, let’s first understand, how document location record is created in Dynamics 365 in case folder structure hierarchy. Here is the screenshot of the document location records, when we have uploaded document under opportunity created HIMBAP customer.
workorderflow6
As you can see in above screenshot, 1 record is created for the Account folder in the SharePoint site location. After that we have record 2 created for HIMBAP account under the Account location. Further Opportunity record is created under the Account folder because we have implemented folder hierarchy structure. After that Demo opportunity record is created which referred Opportunity document location record, so these records are related using following sequence.

workorderflow5

And we need to implement the same sequence for our work order entity. We will discuss document location part in the next article, so stay tuned !!

Source: Mahendra Pal


Updating from party in Email
Category: Changing email from partylist,CRM Dvelopment Series,Dynamics 365,Dynamics 365 CE Online,update from in email using plugin Author: HIMBAP Date: 11 months ago Comments: 0

Introduction
Recently while working on one business requirement where client had two business unit and they were using contacts specific to business unit which means they can have duplicate records for contact or account. While email coming into CRM they wanted to update email from with correct contact from correct business unit if wrong contact is auto populated by CRM. In this article we are going to provide details how we can update from using pre operation plugin.

Requirement
Check from party contact business unit, if it’s not correct update from with correct contact.

Details
We can retrieve from party list from entity object and loop through it like following

if (emailEntity.Contains("from")) {
 EntityCollection from = emailEntity.GetAttributeValue < EntityCollection > ("from");
 //create sender list
 EntityCollection senderList = new EntityCollection();
 if (from != null) {
  from.Entities.ToList().ForEach(party => {
   Guid newContact = Guid.Empty;

   //get party list
   EntityReference partyId = party.GetAttributeValue < EntityReference > ("partyid");
   string contactName = party.GetAttributeValue<string>("addressused");
   
   //process partylist
  
  });

 }

}

Our requirement is to check if from party list is contact type if yes, get and check if it is from correct BU if not get contact from correct BU, if not present create it and set it under from

if (partyId.LogicalName != null && partyId.LogicalName == "contact") {
 //retrieve current associated contact
 Entity currentAssociatedContact = emailLogic.GetContact(partyId.Id);

 //validate for correct contact 
 if (!CheckContactForBU(currentAssociatedContact, ownerid)) {
  //create contact in correct BU
  newContact = CreateContact(contactName, ownerid);

  //add partylist to from
  Entity partyFrom = new Entity("activityparty");
  partyFrom["partyid"] = new EntityReference("contact", newContact);
  partyFrom["addressused"] = contactName;

  senderList.Entities.Add(partyFrom);
 }
}

And finally we can assign sender list to from like following

if (senderList.Entities.Count > 0)
                            {

                                emailEntity["from"] = senderList;
                             }

We need to use this code on pre operation of email entity.This way we can change from email address before creation as after record created it can’t be changed.

Hope it will help someone !!

Source: Mahendra Pal