Archive

Archive for the ‘CRM’ Category

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

[Step by step] Basic Canvas app using Dynamics 365 as Data Source – Part II

November 13, 2019 Leave a comment

This article is continuation to the Part I where we had gone through the following steps:

  • Creating a basic Canvas app
  • How to add a Dynamics 365 Data source.
  • How to add a Gallery to show list of records
  • How to create a new record using ‘Form’ control

In this article, lets see how we perform the ‘Edit’ record by

  • Adding a new ‘Edit Contact’ screen
  • Adding an ‘Edit’ icon to the Gallery item
  • On click of ‘Edit’ icon, redirect to ‘Edit Contact’ screen

Design ‘Edit Contact’ screen:

  • Add a new screen to the Canvas app and rename it to ‘Edit Contact’
  • Add a form to the ‘Edit Contact’ screen by navigating to ‘Insert -> Forms -> Edit’
  • Rename the form to ‘formEditContact‘ and set below properties
    • Set ‘DataSource’ to ‘Contacts’ (i.e., Dynamics ‘Contacts’ Data Set Name)
    • PA_Edt1
    • Set ‘Item’ to ‘galContacts.Selected’ (i.e., Selected Item in the Gallery)
    • PA_Edt2
  • Add a Save icon to the screen and set ‘OnSelect’ as

SubmitForm(formEditContact);Navigate(ManageContacts);

PA_Edt3

  • In the above statement
    • SubmitForm(formEditContact) – Saves the content and updates the Contact.
    • Navigate(ManageContacts) – Post Save, redirects to ‘ManageContacts’ screen (i..e, Gallery screen)

Add ‘Edit’ Icon to Gallery:

  • Go to the ‘ManageContacts’ screen.
  • Select ‘galContacts’ Gallery control and click on ‘Edit Gallery’ icon.
  • Now add a new ‘Edit’ icon to the Gallery item.
  • Set ‘Edit’ icons ‘OnSelect’ as

EditForm(formEditContact);Navigate(EditContact,ScreenTransition.Fade);

PA_Edt4.PNG

  • In the above statement
    • EditForm(formEditContact) – Sets the ‘formEditContact’ form control with selected item from Gallery on ‘EditContact’ screen.
    • Navigate(EditContact,ScreenTransition.Fade) – Navigates to ‘EditContact’ screen.

Test the Application:

  • Run the ‘Application’ and click on ‘Edit’ icon.

PA_Edt5

  • In the next screen, change the data and click on Save icon.

PA_Edt6

  • You should see the modified values in the ‘galContacts’ Gallery.

PA_Edt7

In the next article, we will see how to render ‘Option Sets’ and ‘Look up’ controls.

🙂

Categories: CRM

[Dynamics On-Premise] Mailbox Error – Server does not support secure connections

November 12, 2019 Leave a comment

Other day while configuring ‘Mailbox’, we got ‘Server does not support secure connections‘ exception, while approving the Mailbox using ‘Approve Email’ button.

EmailBoax_1

Reason:

Fix:

EmailBoax_3

  • We can set the ‘Use SSL for Incoming/Outgoing Connection’ properties either by making an SDK call or by updating ‘EmailServerProfileBase’ table in DB.

EmailBoax_2

🙂

[Step by step] Basic Canvas app using Dynamics 365 as Data Source

November 8, 2019 1 comment

In this article, I am going to provide steps to build a basic Canvas app which uses Dynamics 365 (CDS) as Data Source.

If you are new to Power Apps, refer my blog on steps to get started.

The App we are going to build will have 3 screens.

  • Manage Contacts – Displays the list of Contacts using ‘Gallery’ control.
  • Create Contact – Creates a new Contact.
  • Edit Contact – Updates an existing Contact.

Create a new Canvas app:

  • Connect to the Power Apps portal and select the ‘Environment’.
  • Create a new ‘Canvas app from blank’.

PA_Env3

Connect to Dynamics 365 data source:

Now we have the blank App and as a first step, create a new data source by connecting to your D365 instance using ‘Dynamics 365’ connector.

  • Click on the ‘Data source’ tab.
  • Under the ‘Connectors’, select ‘Dynamics 365’ and choose the ‘dataset’.
    • ‘dataset’ is your Dynamics organization name.

PA_Env4

  • Next, under the ‘Choose a table’ pane, select the entities you would like to work with.
    • I’ve chosen ‘Contacts’ entity for this App

PA_Env5

  • Click on ‘Connect’
  • You should see the ‘Contacts’ table under ‘Data sources’ as below:

PA_Env20

Design ‘Manage Contacts’ screen:

Now we have ‘Data source’ ready and lets design our first screen.

  • By default the Canvas app will have a screen.
  • Rename the out of the box screen to ‘ManageContacts’
    • Providing appropriate name to the controls is a best practice.
  • As we need to display available ‘Contacts’ on the screen, select ‘Insert -> Gallery’ and choose ‘Blank Vertical’.
    • ‘Gallery’ is a grid kind of a control.

PA_Env6

  • Now we need to map ‘Contacts’ table to the Gallery.
  • Select the ‘Gallery’ and click on ‘Edit gallery’ icon.

PA_Env7

  • In the ‘Select a data source’ pane, select ‘Contacts’ table. Now the ‘Gallery’ gets mapped with ‘Contacts’ from Dynamics.

PA_Env8

  • To display the Contact details (i.e., Full Name, Email, etc…), add ‘Label’ controls to the ‘Gallery’ and rename the Labels with meaningful names.
  • Labels will not show anything until you map them with the Contacts field.
  • So, select the Label and in the ‘Text’ property, type ‘ThisItem.{field_Name}
    • To map, ‘Full Name’ of the Contact to a label, set ‘Text’ as ThisItem.’Full Name’

PA_Env9

Design ‘New Contact’ screen:

In the ‘Manage Contacts’ screen, we configured a ‘Gallery’ which displays all the Contacts. Now lets design a ‘New Contact’ screen.

  • Add a ‘New Screen’ and rename it.
  • To Create/Edit records, we need to add ‘Forms’ control
    • ‘Edit’ form: Use this to Create or Edit a record.
    • ‘Display’ form: Use this to display the record (Read-only).
  • So, lets add a new ‘Edit’ form to the screen and rename it to ‘formCreateContact‘.

PA_Env12

  • Next, we need to map the ‘formCreateContact’ to ‘Contacts’ Data source and then select and arrange the ‘Contact’ fields, which allows us to input and save.
    • Set the ‘DataSource’ property of ‘formCreateContact’ to ‘Contacts’
    • Click on the highlighted link and add the required columns and click ‘Add’.

PA_Env13

  • Next, we can rearrange the columns using ‘Move up’ and ‘Move down’ options.

PA_Env14

  • We can also set ‘Columns’ to 1 of the ‘formCreateContact‘ which arranges the fields in a single column.
  • Add ‘Save’ icon to the ‘CreateContact’ screen.

PA_Env16.PNG

  • As we need to save the ‘Contact’ (i.e., Submit the Form) on ‘Save’ icon click, add below statement

SubmitForm(formCreateContact);

Link ‘Manage Contacts’ screen and ‘New Contact’ screen:

Now, we have the ‘New Contact’ screen ready. Lets hook it up to ‘ManageContacts’ screen.

  • Go to ‘ManageContacts’ screen and add + icon.
  • There are 2 key steps to create a new Contact
    • First create a new form of type ‘formCreateContact’.
    • Navigate to ‘New Contact’ screen.
  • We need to execute these key steps on click of + icon.
  • Select the + icon and on the ‘OnSelect’ event, add below statement

    NewForm(formCreateContact);Navigate(CreateContact);

PA_Env15.PNG

  • That’s it, run the App and you should be able to see the Contacts on ‘Manage Contact’ screen.

PA_Preview1.PNG

  • Click on + icon, which will take you to ‘New Contact’ screen.

PA_Preview2

  • Lets see ‘Edit Screen’ and Navigation’s in next article.

🙂

 

Categories: CRM, PowerApps Tags: ,

ADX Portals – Cannot register for ‘OnSendingHeaders’ event

November 5, 2019 Leave a comment

Other day, while configuring portal on a new CRM instance, portal shown error page, up on clicking the ‘Apply’ button.

License_Error1

There were no details on error screen to deduce the reason. So we had to go to the server where our portal website hosted.

When checked the ‘Event Viewer’ logs in Portal server, there was this following exception:

Exception type: InvalidOperationException

Exception message: Cannot register for ‘OnSendingHeaders’ event after response headers have been sent.

Reason & Fix:

  • CRM instance was missing ‘Adxstudio License Key’ record.
  • Post CRM connection, ADX would first check for the valid ‘License Key’. Since there was no ‘License Key’ record, Portal thrown error.
  • To fix this, add the ‘License Key’ by going to ‘Advanced Find -> ADXStudio License Keys‘, add a key.

License_Error2

🙂