Archive

Archive for the ‘CRM’ Category

Power Platform – Pass external API collection from Power Automate to Canvas App

February 9, 2020 1 comment

In this article, lets see how to pass an external API’s json collection from Power Automate(Formerly ‘Microsoft Flow’) to a Canvas application.

For this example, I am going to use ESRI  mapping service API, in my Power Automate Flow. Refer here to know more about ESRI. You may also use other APIs as per your convenience.

ESRI API is url based and returns the ‘Address Suggestions’ in json format.

Flow_Json_3

Before we start lets make sure to meet all the prerequisites.

Prerequisites:

  • Subscribe to 30 days trial and get Office 365 account.
  • Connect to Power Automate portal using Office 365 account to build Power Automate flow.
  • Connect to Power Apps maker portal using Office 365 account to build the Canvas App.
  • ESRI api URL – Refer my previous article on the usage of ESRI or you can simply use this url

Once all prerequisites are met, here is the high level design:

  • Create a new Power Automate flow and call ESRI API to fetch Address Suggestions.
    • You can take any open API which returns json collection.
  • Parse the ESRI API Response to json collection.
  • Create a new Canvas app
  • Trigger Power automate flow from Canvas App and read the collection.

Lets get started.

Steps to configure the Power Automate Flow:

  • Connect to Power Automate portal
  • Create a new ‘Instant flow’ by selecting the right Environment.

Flow_Json_1

  • Provide a name ‘GetAddressSuggestions’ and select trigger as ‘PowerApps’

Flow_Json_2

  • To call ESRI api, add a new ‘HTTP’ action.

Flow_Json_4

  • Choose Method as ‘GET’ and in URI paste the ESRI url as mentioned in prerequisite section.

Flow_Json_5

  • Next, we need to parse the response from ESRI api. As the ESRI results would be in json format, add ‘Parse JSON’ action.

Flow_Json_6

  • In ‘Parse JSON’ action,
    • set Content as ‘Body’ from HTTP action.
    • Next we need to provide the json schema of ESRI response. To do that, click on ‘Generate from sample’.
    • Flow_Json_9
    • Now copy the response from ESRI API (Copy the browser’s output using ctrl+a+copy)
    • Flow_Json_7
    • Paste in the ‘Insert a sample JSON Payload’ window and click ‘Done’.
    • Flow_Json_8
    • If no warnings, your ‘Parse JSON’ pane should look as below.
    • Flow_Json_10
  • As we completed the ESRI response capture and parsing to json, now we need to pass the captured json response to Power App.
  • To pass the json response to Power App, add a new ‘Response’ action.

Flow_Json_11

  • In the ‘Response’ pane,
    • Set the ‘Body’ to ‘Body’ from ‘Parse JSON’.
    • Flow_Json_12
    • Expand ‘Show advanced options’ and click on ‘Generate from sample’.
    • Copy the response from ESRI API and paste in the ‘Insert a sample JSON Payload’ window and click ‘Done’. (Same step like we did in ‘Parse JSON’ pane).
    • ‘Response’ pane should look as below with no warnings.
    • Flow_Json_13
  • Run the flow and make sure it ran successfully.

Flow_Json_18

Steps to configure the Canvas App:

As we completed the Power Auto Flow, now its time to consume the Power Automate flow response from Canvas App by following the steps below

  • Connect to Power Apps maker portal using the same Office 365 account.
  • Create a new Canvas App.
    • Note: Make sure the same Environment used for Power Automate is selected.
  • Add a new button.
  • Select the button, from the ribbon menu, click on ‘Action -> Power Automate’.
  • From the pane select the ‘GetAddressSuggestions’ Power app flow.

Flow_Json_14

  • After few seconds, you would see the Run() command auto populated as below.

Flow_Json_15

  • As we going to get json collection from flow, lets capture the json collection to a collection variable ‘collAddress’ using ‘ClearCollect()’. Refer article to know more about ‘ClearCollect()’.
  • With the ClearCollect() and Run() functions, the final ‘OnSelect’ statement should look as below.

Flow_Json_16

  • Lets run the App and click on the button. Application takes couple of minutes to complete the run.

Flow_Json_17

  • Post run, check the collection returned from flow by going to ‘File -> Collections’ tab.

Flow_Json_19

  • You can also add a ‘Data table’ control and display the results returned from flow as below

Flow_Json_20

🙂

 

Power Platform – Pass json collection from Canvas App to Power Automate

February 9, 2020 1 comment

Refer my previous article for steps to pass json collection from Power Automate to Canvas App.

Now lets see how to pass json collection from a Canvas app to Power Automate flow.

Before we start lets make sure to meet all the prerequisites.

Prerequisites:

  • Subscribe to 30 days trial and get Office 365 account.
  • Connect to Power Automate portal using Office 365 account to build Power Automate flow.
  • Connect to Power Apps maker portal using Office 365 account to build the Canvas App.

Once all prerequisites are met, here is the high level design:

  • Create a new Canvas app.
  • Prepare a json collection.
  • Create a new Power Automate flow.
  • Trigger Power automate flow from Canvas App by passing the collection as parameter.
  • Read the json collection from Power Automate flow.
  • Create ‘Contact’ records in CDS.

Lets get started.

Steps to configure Canvas App:

  • Connect to Power Apps maker portal using the Office 365 account.
  • Create a new Canvas App.
    • Note: Make sure the same Environment used for Power Automate is selected.
  • Add a new button ‘Generate Sample Collection’.
  • On button’s ‘OnSelect’ prepare a json collection using ‘ClearCollect’ function as below.

Flow_Json_21

  • Once your run the App and click ‘Generate Sample Collection’ button, you should see the collection from ‘File -> Collections’ tab.

Flow_Json_22

Steps to configure the Power Automate Flow:

  • Connect to Power Automate portal using the same office 365 credentials used to connect to Power App portal.
  • Create a new ‘Instant flow’ by selecting the right Environment.

Flow_Json_1

  • Provide a name ‘GetCollectionFromPowerApp’ and select trigger as ‘PowerApps’.
  • Now, we need to read the collection passed from Canvas app to a variable. Lets add a new ‘Initialize Variable’ action.
  • In the ‘Initialize Variable’ action,
    • Provide variable name by setting ‘Name’ field. I set it as ‘collPersons’.
    • Type: String
    • Select ‘Value’ and click on ‘Ask in PowerApps’. A auto generated name would appear and select the same.
    • Flow_Json_25
  • Once we receive the collection and stored in a string variable ‘collPersons’, next we need to parse in to json collection.
  • Add a new ‘Parse JSON’ action.
  • In ‘Parse JSON’ action,
    • set Content as ‘collPersons’ from ‘Initialize Variable’ action.
    • Next we need to provide the json schema coming from Canvas app. To do that, click on ‘Generate from sample’.
    • Copy the json collection formed in Canvas app using ClearCollect function and paste as below.
    • Flow_Json_27
    • If no warnings, your ‘Parse JSON’ pane should look as below.
    • Flow_Json_28
  • Now we got json collection parsed and we are good start final step, creating records to CDS.
  • Add ‘Create a new record’ CDS action and select the ‘Environment’ and ‘Entity Name’

Flow_Json_33

  • Set the attributes (Last Name and Email) from ‘Parse JSON’ action.

Flow_Json_34

  • Once you set variables in ‘Create a new record’ CDS action, flow would automatically wrap the action in ‘Apply to each’.

Flow_Json_29

Trigger the Power automate flow from Canvas App:

Now we have Power automate flow with the logic to read and parse the json collection and add them to CDS as Contact records, lets trigger the flow from Canvas App.

  • Open the Canvas app created in above sections.
  • Add a new button ‘Share Collection To Flow’
  • Select the button, from the ribbon menu, click on ‘Action -> Power Automate’.
  • From the pane select the ‘GetCollectionFromPowerApp’ Power app flow.
  • After few seconds, you would see the Run() command auto populated. Now pass the ‘collPersonalInfo’ collection wrapped in JSON() function.
    • JSON() function is required to convert the ‘collPersonalInfo’ collection to JSON string as the Power Automate flow expects ‘String’ variable as first action.
  • Finally ‘OnSelect’ should look as below.

 

Flow_Json_30

  • Now run the App and click ‘Share Collection To Flow’ button, post run, go to Power automate flow’s history and you should see it ran successfully.

Flow_Json_31

🙂

Categories: CRM, PowerApps Tags: ,

Power platform 2020 release wave 1 – Plan and features list

February 7, 2020 Leave a comment

The Power Platform release plan (formerly release notes) for the 2020 release wave 1 has been published with great new features.

Refer here for the details and download from here for the full list of features.

Following are the standout features for me:

  • Canvas apps:
    • Monitor tool – Allow makers to diagnose and troubleshoot their applications quicker
    • Create an app from data in a landscape format instead of just a phone layout.
  • Model Driven Apps:
    • Edit/Create related records without navigating away – Users do not have to navigate away from a form to create or edit a related record

PAPP_Wave2020_2

  • Power app Portal:
    • Web APIs for CRUD operations on Common Data Service entitiesThis is much awaited feature as former portal versions would only allow Read outside of ‘Entity Forms’ using Liquid script.
    • Power BI Embedded component in portal designerPortal provides the first party integration with Power BI by using the liquid tags
    • Simplified themes in portals Studio
    • Support for additional entities in global searchNow you can enable Global Search on Custom entities as well using a ‘Site Setting’ configuration.

PAPP_Wave2020_1

  • Power Automate:
    • Solutioning support for UI flowsWith this feature, you can create your UI flows in solutions, easily export them into a package, and then import them across different environments for your ALM needs.
    • Azure integration with Power AutomateOption to create flows by using a template from the Azure portal
    • Copy and paste in Power AutomateIf you want to duplicate actions in the Power Automate designer, you can now copy and paste them.
    • UI FlowsWith UI flows in Power Automate, you can record mouse clicks, keyboard use, and data entry to automate manual, repetitive, and time-consuming tasks to improve workplace productivity
  • Power Virtual Agent:
    • Add a Power Virtual Agents bot into Power Apps canvas app.
    • Add images and videos to topics.

🙂

 

D365 – Shifting from Dynamics Workflow to Power Automate flow

December 11, 2019 Leave a comment

First things first, Microsoft Flow is now Power Automate.

If you are either a dynamics developer or administrator, off late you might have noticed a flashing banner while creating new Process from Dynamics instance.

Flow_Scope_4

From the banner, its clear that Microsoft recommends ‘Power automate flows’ over conventional ‘Process’.

In this article, I am going to cover basics of following items, which helps you in decision making to some extent.

Lets get in to the details.

CDS connector vs Dynamics connector:

When you are creating a flow, you need to choose b/w CDS and Dynamics connector.

The key differentiation when switching from Dynamics ‘Process’ to ‘Flow’ is,

  • With CDS connector you can set ‘Scope’ and ‘Filter Attributes’ but not with Dynamics connector.

Lets understand this with an example.

Create a flow with CDS connector:

  • Connect to your Power automate portal
  • Click on ‘+ Create’ tab and choose ‘Automated flow’

Flow_Scope_16

  • In the new window, choose the ‘Common Data Service’ connector.

Flow_Scope_0

  • Under the ‘Triggers’, select ‘When a record is updated’ trigger.

Flow_Scope_2

  • If you notice, under ‘When a record is updated’, there are ‘Scope’ and ‘Attribute Filter’ options.
    • Scope : Scope decides the affected records up on flow execution. Get more details here.
    • Flow_Scope_1
    • Attribute Filter: If no filtering attributes are set flow will execute on every field updates. Add attribute filters to minimize flow execution, only on specified field updates.
    • Flow_Scope_3
  • Now add an action from the ‘Actions’ list. I’ve added a ‘Create a new record’ action.

Flow_Scope_17

Create a flow with Dynamics 365 connector:

  • Connect to your Power automate portal
  • Click on ‘+ Create’ tab and choose ‘Automated flow’
  • In the new window, choose the ‘Dynamics 365’ connector.

Flow_Scope_13

  • Under the ‘Triggers’, select ‘When a record is updated’ trigger.

Flow_Scope_14

  • This time, under ‘When a record is updated’ there are NO ‘Scope’ and ‘Attribute Filter’ options.

Flow_Scope_15

  • Which means, the flow will trigger on all field updates and there is no provision of ‘Attribute Filter’ in Dynamics 365 Connector.

Automated flow vs Instant flow (i.e., On-demand process):

One of the common questions from Admins is, how can they create an ‘On-demand’ power automate flow similar to conventional ‘On-demand’ workflow. The answer is Instant flow.

Lets see how to create a simple on-demand flow and run.

Create an Instant Flow:

  • Connect to your Power automate portal
  • Click on ‘+ Create’ tab and choose ‘Instant flow’
    • Note: You can also create ‘Instant flow’ from Dynamics application.
    • Go to the entity, from ‘Flow’ menu, click on ‘Create a flow’.

Flow_Scope_18

  • In the new window, choose the ‘Common Data Service’ connector.
  • Under the ‘Triggers’, select ‘When a record is selected’ trigger.
  • Select the ‘Environment’ and ‘Entity Name’
    • Environment: If you want your flow to always trigger based on an event in a specific environment, select that environment or Choose (Default), which will always use the database within the environment in which Power Automate runs.
  • Now add an action from the ‘Actions’ list. I’ve added a ‘Create a new record’ action.

Flow_Scope_8

  • In above screen, I am setting ‘Transaction Audit’ entities ‘Name’ field with concatenating ‘Transactions’ entities ‘Name’ and current date (i.e., utcNow()).
    • Use ‘Dynamic content’ window, to refer the values from Previous step.

Trigger Instant Flow:

  • Connect to Dynamics instance and open the record for which you have flow registered. In my case, my flow registered on ‘Transaction’ Entity.
  • From the ‘Flow’ menu, select your flow.

Flow_Scope_5.PNG

  • Click on ‘Run flow’

Flow_Scope_7

  • Make sure you got the success screen as below.

Flow_Scope_9

  • Now check whether the Action executed. In my example, I am creating a child record (i.e., Transaction Audit)

Flow_Scope_10

Formatting Dates:

If you would have noticed the previous screen, the ‘Name’ field of the ‘Transaction Audit’ was set to UTC date format.

To format the date to your choice, use formatDateTime function in your flow’s ‘Expression’.

Flow_Scope_11

Save and run the flow, you should see the formatted date as below.

Flow_Scope_12

Notes:

  • One more edge CDS connector over Dynamics connector is in terms of execution speed. More details

🙂

 

 

 

 

 

 

 

 

Dynamics workflow – Unable to set Email ‘Regarding’ field

December 3, 2019 Leave a comment

Other day, while working on a straight forward ‘Send Email’ using a ‘Workflow’, I could not set the ‘Regarding’ field on ‘Email’ form.

Scenario:

  • Create a new custom entity ‘Transaction’.
  • Send an Email when a new ‘Transaction’ record gets created.

So, I created a new workflow on ‘Transaction’ entity and added ‘Send Email’ step.

SendMail_0.PNG

On the ‘Email’ configuration screen, all I could see was a blank ‘Look for:’ field.

SendMail_1

Reason & Fix:

  • ‘Activities’ option was not enabled on the ‘Transaction’ entity.

SendMail_2

  • Enable ‘Activities’ and publish.
  • Go to the workflow and I got the Entity Reference in ‘Look for:’ field.

SendMail_3

Its one of those days where we struggle for trivial problems 🙂

 

Categories: CRM Tags: ,

ADX/Dynamics portal – Setting up password policies

November 21, 2019 Leave a comment

If you want to imply password policy (i.e., Certain length, must have a digit, etc…) during the portal registrations, following entries need to be added to ‘Site Settings’ entity.

ADX_PasswordPolicy_1.PNG

Name Value
Authentication/UserManager/PasswordValidator/AlphanumericUserNames TRUE
Authentication/UserManager/PasswordValidator/RequireDigit TRUE
Authentication/UserManager/PasswordValidator/RequiredLength 9
Authentication/UserManager/PasswordValidator/RequireLowercase TRUE
Authentication/UserManager/PasswordValidator/RequireNonLetterOrDigit TRUE
Authentication/UserManager/PasswordValidator/RequireUppercase TRUE

If the password does not meet any of the configured setting values, you gonna get OOB validation error as follows:

ADX_PasswordPolicy

For more ‘Authentication’ related settings, refer the article

Refer this article for portals client scripting.

🙂

Dynamics/ADX Portal – Handling ‘Page flickering’ due to long running scripts

November 18, 2019 Leave a comment

In our portal, we have a couple of entity forms with JScript registered on page load event, which hide/show or enable/disable controls based on business rules.

Due to the script execution delays, end users were experiencing page flickering on load.

What is flickering:

  • If you have a script with hide/show control logic, on page load event, end user would see the unintended controls momentarily before your script kicks in.
  • Assume that you have an ‘Option Set’ field on Entity form, which you hide based on logged in user’s web role using jscript. What if there is a lag in your script execution, end user would see the ‘Option Set’ for a split second, before it gets hidden.

How to handle flickering in Portals:

  • We have added below statements in both the ‘Custom JavaScript’ and ‘Custom CSS’ to the portal Web Page’s ‘Advanced’ tab.

Portal_Loading

  • The above technique works on a simple rule;
    • Hide all the controls before the page loads (i.e., using CSS).
    • Let the script with your business rules executes.
    • Show the controls only when the Page load completes (i.e., using $(window).load event).
  • Lets dissect the statements added in ‘Custom JavaScript’ and ‘Custom CSS’.
    • #content_form is the OOB portal ‘form’ control’s object, available in all portal pages.

Portal_Loading_2

    • To hide all the controls, set the #content_form { display: none; } in ‘Custom CSS’.
    • Now, show the #content_form only when page load completes, by setting ‘display’ to ‘block’ in $(window).load event.

Notes:

  • Following are the events, as per their order, during any Web Page’s Load.
    • $(document).ready
      • document.ready triggers when the DOM is ready, e.g. all elements are there to be found/used, but not necessarily all the content.
    • $(window).load
      • window.load event is fired after whole content is loaded like page contain images,css etc.
  • We can also show ‘Loader’ symbol during page load. All we need is ‘Spinner’ image and hide/show using the specified technique.

🙂

 

Categories: CRM