Script

Wednesday, June 3, 2020

PowerApps AI Builder : Scan Business Card and Create Record in D365 CE


PowerApps AI Builder gives a great option to scan the business card.

In this post, we going to see how to use Business Card Reader control and creating a contact record in D365 CE using Power Automate

Step 1 : Login to PowerApps using https://make.powerapps.com



Step 2 : Select AI Builder -> Build and click on the Business Card Reader



Step 3 : Select Use in an app



Step 4: App page will open with business card reader control added in the screen. Rename the BusinessCardReader1 control as BCR



Step 5 : Add the controls to the screen to capture the business card details



Step 6 : To capture Full Name from business card, select the full name text control and add the expression as BCR.FullName



Step 7 : To capture Address City from business card, select the City text control and add the expression as BCR.AddressCity





Step 8 : Remaining fields will be mapped in the same way

Step 9 : From the PowerApps builder window, select Action -> Power Automate
Selecting Create a new flow from the dialog will take you to Power Automate window
Establish a connection and add a new step to Create a new record in CRM



Step 10 : Select the field to map and click Add Dynamic Content. Selecting Ask in PowerApps will create a mapping variable in power automate. It allow us to pass the data as a parameter from PowerApps. We can pass multiple values as parameter in this way
Once the field mapping is completed, Save the flow




Step 11 : Select the Save button and add the expression as CreateContact.Run(param1,param2,…..)
CreateContact : Name of the flow we created in previous step




Step 12 : We can see the mapping the created in power automate is displayed as parameters



Step 13 : Expression after setting value for parameters



Demo :



Contact record created in D365 CE with the details captured in PowerApps


Thursday, May 14, 2020

Power Automate : Integrate D365 CE and Twilio to Send SMS

Step 1 : Create a Twilio free trial account using https://www.twilio.com/try-twilio

Step 2 : From the Twilio Dashboard, click Get a Trial Number to get a Phone number

Step 3 : Copy the following details from Twilio Dashboard,
  1. ACCOUNT SID
  2. AUTH TOKEN
  3. PHONE NUMBER (Generated from step 2 above)

Step 4 : Sign in to Power Automate using your credentials

Step 5 : Select Create from the left navigation and click on Automate Flow



Step 6 : Configure and select your Dynamics CE Organization Name and respective entity. In my scenario, When a new Contact record is created, SMS will be sent to respective Contact (Mobile Phone)



Step 7 : After configuring Dynamics CE organization and entity, add next step and select Twilio
Select Send Text Message (SMS)



Step 8 : Enter the Connection details
Connection Name : *Enter some connection name*
Twilio Account Id  : *ACCOUNT SID copied from Twilio Dashboard should paste here*
Twilio Access Token : *AUTH TOKEN copied from Twilio Dashboard should paste here*
Click Create to establish connection



Step 9 : Once connection with Twilio is successful, enter the following details,
From Phone Number : *PHONE NUMBER generated from Twilio should be entered*
To Phone Number      : *Map the destination Phone Number*
Text                               : *Custom message to send*


Step 10 : In my scenario, mapped the Mobile Phone field from Contact entity with custom message


Step 11 : Click Save
Step 12 : Go to your Dynamics CE environment and create new Contact with following details,
  1. Full Name
  2. Mobile Phone
Step 13 : Save the Contact record to trigger the flow
Step 14 : SMS will be delivered to respective Contact

Wednesday, November 20, 2019

Javascript : Accessing Query String Parameters

The below script is to get the query string values passed to CRM web resource,
       
function parseQueryString(qs, opts) {
    var queryString = qs || window.location.search || "";
    var queryStringRegularExpression = /(?:\?|&|^)([^=]+)=([^&]*)/ig;
    var qsMatch = queryStringRegularExpression.exec(queryString);
    var paramKey;
    var paramVal;
    while (!!qsMatch) {
        paramKey = decodeURIComponent(qsMatch[1] || "").toLowerCase();
        paramVal = decodeURIComponent(qsMatch[2] || "");
        if ((paramKey === "data") && !!paramVal) {
            parseQueryString(paramVal, opts);
        } else if (!!paramKey && !!paramVal) {
            opts[paramKey] = paramVal;
        }
        qsMatch = queryStringRegularExpression.exec(queryString);
    }
}
       
 
Usage of Query String method :
       
var qsOptions = {};
parseQueryString(location.search, qsOptions);
 
// Get your parameters here
var name = qsOptions.name;
var country = qsOptions.country;
       
 
Sample Webresource URL
       
http://servername/WebResources/new_/AccesingQueryString.htm?Data=name%3DfullName%26country%3DIndia

 

Tuesday, November 19, 2019

D365 CE : Switching Between Unified Interface and Classic Web Client


"Use Unified Interface only" option is no more available in Dynamics CE System Settings.

To view application in classic web client, settings can be changed only through Admin Centre, Please check the steps below,

Step 2 : Navigate to Environments
Step 3 : Select the respective environment and click Settings
Step 4 : Expand Product and select Behaviour
Step 5 : Enable/Disable "Use Unified Interface only"
Step 6 : Click Save



Thursday, April 11, 2019

{Fix} Error : SYSTEM POPULATED FIELD FOR THE XML REPRESENTATION OF THE LAYOUT OF THE FORM OR DASHBOARD

Error : Importing solution in CRM throws “system populated field for the xml representation of the layout of the form or dashboard”

Solution:
When you get this error,follow the below steps to get this resolve,
  • Note the entity name from import customization window
  • Compare the custom fields schema name between source and target environment
           for e.g
            Source environment : crm_CustomField
            Target environment : crm_customfield

Note that field name between source and target environment are vary in above step,where C and F are caps in source and its small letters in target environment,this cause the import issue

  • List down the conflict fields
  • Recreate the fields and make sure fields are sync between source and target environment
            for e.g
              Source environment : crm_CustomField
              Target environment : crm_CustomField