Tuesday, 13 August 2019

Unable to build VS 2019 solution with Dynamics 365 Developer Toolkit Installed

Issue:

I have installed the Developer Tool kit in Visual Studio 2019, created a Dynamics 365 Package project, and a CRM customization project but I cannot build the VS solution after importing my CRM solution into VS. I am facing following error:


Severity    Code    Description    Project    File    Line    Suppression State
Error        The command "REM SET AssemblyVersionDefinitionFile=
          REM SET AssemblyVersionName=
          "D:\...\CRM\SDK\Bin\SolutionPackager.exe" -a:pack -z:"bin\Debug\....Customisations.zip" -f:"obj\Debug\\BeforeLoc"" exited with code 3.    CRMSSolution      


Resolution:


  • Unload your customization project in visual studio 
  • Edit your Dynamics 365 Package.CSPROJ.file either in Notepad++ or Notepad.
  • Find following lines 

<SolutionPackagerDir>C:\365SDK\Sdk\SDK\Bin</SolutionPackagerDir>

<SolutionLocToolsDir>C:\365SDK\Sdk\SDK\Bin</SolutionLocToolsDir>

and replace the highlighted part with local system path

or

Move the SDK Bin folder to other location and give that path in place of highlighted path.

Monday, 22 July 2019

Create Lead in Dynamics 365 by Scanning Business Card









As business cards are part of an introduction, they are important for making a favorable first impression. An attractive, eye-catching business card with all the relevant contact information can capture the attention of your prospect and help you remain in her memory well after your initial meeting.

Business cards are typically handed out at meetings, then often misplaced or lost. Sales professionals need a way to quickly capture information from these cards, freeing them to  focus on more important tasks. Scanning business cards is particularly useful when on the go, at conferences, or offsite meetings.




One of the most basic requirement of customer is to directly feed the information in Dynamics by scanning the Customer Business Card instead of manually filling data in CRM by looking at the Card.

Here is the step by step article to understand how to scan business card using PowerApps and capture Lead in Dynamics CE.

Login to PowerApps Portal


















Go to Apps and Create Canvas App





































Choose Blank App and Phone Layout



Go to Insert Tab and Select Business Card Reader under AI Builder (Preview)












Go to Home Tab and Design your Form as below

The Business Card Reader currently can extract the following if a Business Card is detected:

CleanedImage: The image after processing where the business card appears cropped and enhanced from the original image.
CompanyName: The company name in the business card, if found.
Department: The organization department found in the business card, if found.
Email: The contact email found in the business card if any.
FirstName: The contact first name in the business card, if found.
FullAddress: The contact full address in the business card, if found.
FullName: The contact full name in the business card, if found.
JobTitle: The contact job title in the business card, if found.
LastName: The contact last name in the business card, if found.
OriginalImage: The original image before processing.
Phone1: The first phone or fax number detected in the business card, if found.
Phone2: The second phone or fax number detected in the business card, if found.
Phone3: The third phone or fax number detected in the business card, if found.
Website: The website detected in the business card, if found.

For demonstration, we are using only
  • FirstName
  • LastName
  • Email
  • JobTitle
  • Phone
  • CompanyName


Map Textbox Value to Business Card Reader value as shown below. I have shown for FirstName and LastName only. Do it for other Textboxes also.





















Now Go to Action Tab and Click Flows

















Create a New Flow

Connect your CRM Instance, Choose 'Create a new record' option and Select 'Lead' Entity


Set Field value as mention below using 'Ask in PowerApps' option.


Click on 'See More' in order to get 'Ask in PowerApp' option


Click Save to Save the Microsoft Flow.


Go back to PowerApps screen, you'll see Flow with Name: PowerApps button


Click on PowerApps button > Go to Advanced Tab and set the function PowerAppsbutton.Run() value as mentioned below:
















In order to identify the order of Textbox value. Write parenthesis '(' next to Run function, you'll get intellisense as shown below. This shows the field 's order in the same order you have used in your Microsoft Flow to create Lead record.








Set the respective textbox name as suggested by intellisense, For Example - In my case, Intellisense showing LastName field first, hence I have first set the name of Lastname Textbox which is 'TextInput1_1' and so on. In your case it might be different. Change accordingly

















Add one more Screen (as shown below) to show Success Message once Lead is created in CRM. Change the screen UI as shown below (Optional)











































Go to Button and update the function value to as mentioned value.

Navigate function use to redirect user to Success screen once Lead gets created in CRM

















Complete Value:

PowerAppsbutton.Run(TextInput1_1.Text, TextInput1_5.Text, TextInput1_2.Text, TextInput1.Text, TextInput1_3.Text, TextInput1_4.Text); Navigate(Screen2, ScreenTransition.Fade)

Change above textbox and screen names as per your settings


Save your PowerApp
















Click on PowerApp and Run your App



Choose Business Card. It will automatically scan and fill the information in created fields



Click on Create Lead, it will show the Success Screen



Go to CRM > View Created Record



Important Note:
  • Business card scan feature will only be available in the US and EU regions.
  • This feature is available in the Unified Interface only.
  • This feature is currently in Preview (not recommended for Production instance). Officially release date might be in October 2019.




Cheers. Please share your valuable feedback. It means a lot for me.

Wednesday, 13 February 2019

Party List Fields in Dynamics 365





















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.


Thanks for your time. Please do share your valuable feedback. It means a lot for me.

Cheers
Blogger Widgets