Advertisements

Archive

Archive for the ‘CRM’ Category

PowerApps – Create an ‘Account’ in Dynamics 365 from App using Flow

If you are new to PowerApps, please go through my previous blog

In this post, lets build an App with an Account Form and create the record in Dynamics 365.

PA_Flow_5

Prerequisite:

  • You must have a PowerApps account. Refer blog for details.
  • Create a Microsoft Flow with logic to create an Account record in Dynamics 365
  • Build an App and trigger Flow

Steps to create Flow:

  • Login to PowerApps Portal
  • Navigate to Business Logic -> Flows -> Create from blank

PA_Flow_1

  • In the new Flow screen, Choose Action, select ‘Dynamics 365’

PA_Flow_7

  • Select ‘Create a new record’ from Actions.
  • Now we need to put place holders in the fields which we pass data from PowerApp.
  • To add a place holder to ‘Account Name’ field, select the field, in ‘Dynamics content’ window, click on ‘Ask in PowerApps‘ button.
    • A new place holder will get added to ‘Account Name’ field.

PA_Flow_2

  • I repeated the above step for ‘Main Phone’ and ‘Description’ fields.

PA_Flow_3

  • Rename the Flow to CreateAccount and Save

Invoke Flow from PowerApp:

  • To know, how to create a new App and add controls to form, refer my earlier blog
  • To trigger the Flow, select the ‘Create’ button, go to ‘Action -> Flows’
  • From the ‘Data’ window, select the flow created in above section (i.e.,CreateAccount)

PA_Flow_4

  • On ‘OnSelect’ event of button, trigger the Flow ‘CreateAccount’ by calling ‘Run’ method and passing the 3 placeholder parameters.
    • CreateAccount.Run(txtName.Text,txtDesc.Text,txtMobile.Text)
  • Thats it, now its time to test the App

Test the App:

  • Press F5
  • Set the values and click ‘Create’

PA_Flow_5

  • Open the D365 App and you should see new ‘Account’ record.

PA_Flow_6

Refer my earlier article to build an App using Excel as Data Source.

🙂

Advertisements

PowerApps – Build an App using Excel data as Source

August 13, 2018 2 comments

If you are new to PowerApps, please go through my previous blog

In this post, I am going to walk you through building an App using Excel as ‘Data Source’.

I am going to build an App by

  • Prepare an Excel file with data formatted as ‘Table’
  • Place it in ‘One Drive For Business’.

Pre-requisites:

  • You must have a PowerApps account. Refer blog for details.
  • An Excel sheet with data formatted as ‘Table’.
  • ‘One Drive For Business’ account
    • This comes free with Dynamics 365 30 days trail.

Steps to configure Excel:

  • Create an Excel file with some data. I prepared ‘Customer’ records with 4 columns.
  • You should format this data as ‘Table’ as the PowerApp, only consider Tables, which you will notice in next sections.

PA_Excel1

  • Provide name to the Table; We will use this Table name in ‘Power App’. I named my table as ‘Customers‘.

PA_Excel2

  • Save the Excel

Steps to upload Excel to OneDrive:

PA_Excel3

  • Connect to ‘OneDrive’ and upload the Excel File

PA_Excel4

Steps to create App:

  • Login to PowerApps Portal
  • Create a New App with ‘OneDrive for Business’ template, as I uploaded the Excel to OneDrive.

PA_Excel5

  • Note: Its not necessary that you should pick ‘OneDrive for Business’ template, you can even create a ‘Blank app’ and create ‘OneDrive’ connection.
  • Click ‘Create’ to establish App’s connection with ‘OneDrive For Business’.

PA_Excel6

  • Choose the Excel file

PA_Excel7

  • Select the ‘Table’ and click ‘Connect’; This table ‘Customers‘ is nothing but the table name we given in ‘Excel sheet’.

PA_Excel8

  • Now you would experience the power of ‘Power Apps’ as it instantly come up with UI using the excel data. App auto create 3 screens for Browse Screen,Details Screen and Edit Screen.

PA_Excel10

  • You can reorder the columns by selecting ‘Data’ or you can change the ‘Sort Column’ if you want.
  • Finally, press F5 to run the App.

PA_Excel11.PNG

Refer my previous blog to build a simple calculator App.

🙂

 

PowerApps – Step By Step – Build a simple Calculator App

August 12, 2018 3 comments

In my previous article I detailed the steps to get started with PowerApps by signing up to the PowerApps portal.

Now, let me walk you through the steps to create and publish a simple ‘Calculator’ App.

The Calculator App will have 2 Text boxes and an ‘Operation’ dropdown. Upon clicking the ‘Calculate’ button, based on the Operation we either Sum or Subtract the values and show the result.

Calc

Pre-requisites:

  • You must have PowerApps account. Refer my previous article

Steps to build ‘Calculator’ App UI:

  • Connect to the PowerApp studio and click on ‘New App’ of Mode ‘Canvas’
  • From the ribbon, click on ‘Insert’ tab and drag & drop the controls on to the Canvas
  • For the ‘Text Input’ controls, select ‘Format’ as ‘Number’ so that it only allow digits.

Calc_1

  • Add the ‘Dropdown’ control to the Screen
  • Calc_ddl
    • To add “Sum”,”Substract” as options to the ‘Dropdown’, select ‘Items‘ property and set [“Sum”,”Substract”]
  • Add the ‘Button’ control to the screen and set the text as “Calculate”
  • Add 3 labels
    • Label ‘A’, Label ‘B’ and Label ‘Result’

Steps to add the business logic:

  • On buttons ‘OnSelect’ event,
  • Calc_resultbutton
    • Declare a variable “varResult”
    • Read the selected operation (i.e., Sum/Subtract) from the Dropdown
    • Write an If/Else statement
      • Add TextA, TextB; if the dropdown values is ‘Sum’ If(ddlOperation.Selected.Value=”Sum”,txtA.Text+txtB.Text))
      • Subtract TextA, TextB; if the dropdown values is ‘Substract’ If(ddlOperation.Selected.Value=”Substract”,txtA.TexttxtB.Text))
      • Set the Sum/Subtract value to the “varResult” variable using ‘Set‘ method
    • Finally, we should display the result by setting it to ‘Result’ label. So, set ‘Text’ as ‘varResult’

Calc_resultlabel

Time to Test the App:

  • Press F5 to test the App

PAPP_5

Save and Publish the App:

Once you done with testing, its time to Save and Publish the App.

  • To save the App, either press (Ctrl+S) or go to File -> Save

Calc_Save

  • Choose either ‘The Cloud’ option or ‘This computer’
    • ‘Cloud’ option would save the App in your ‘PowerApps’ account
    • ‘Computer’ option would provide the App in .zip folder to save locally.
  • Post save, to make the App available to Users, click on ‘Publish’

Calc_Publish

Notes:

  • PowerApps provides excel like formulas to apply business rules. Refer this blog to get exhaustive list of formulas.

🙂

 

Categories: CRM, PowerApps Tags: , ,

CRM 2011 (on-premise) – Querying Filtered views from CRM DB

We recently working on Data migration from CRM 2011 on-premise to Dynamics 365.

We got the CRM 2011 SQL DB back up, which we restored in our SQL server. But when we run query on ‘Filtered’ views we were getting 0 results.

FilteredView_1

Reason:

  • FilteredViews always run on CRM User context
  • The account I logged in to SQL server is not a CRM User/Service Account and hence Filteredview returning 0 results

Fix:

  • Before you querying ‘Filtered’ view, set the Context to CRM User using GUID
  • Below is the syntax:

— Set the Context

DECLARE @userid uniqueidentifier;
SET @userid = convert(uniqueidentifier, ‘123A81A3-89C3-E411-B6EF-441EA155CAB5’);
SET CONTEXT_INFO @userid;

–Execute the query
Select top 10 name,statecode,statecodename from FilteredAccount (nolock)

  • GUID used in above query is the valid CRM user’s GUID.
  • Now we should get the Accounts based on the Privilege and Access level of the User GUID we set the context with.

FilteredView_2

Dynamics 365 – Different types of User Accounts and License consumption

Other day I was asked a question “What are the options to create/migrate users in Dynamics 365 application with no license consumption”

The options are

  • Create a User of type ‘Stub User’ which does not consume license
  • Sync a User from O365 to Dynamics 365 and remove the license later. This approach deactivates the User in D365 and free up the license.
  • Create an Application User
  • Create an Administrative User account
  • Create a Non-Interactive User account

To know different options is crucial, especially, when you are migrating the Users from legacy systems and the Users are not expected to access the D365 application which should not cost any licenses.

In this article, I am going explain the different type of Users and how they consume the licenses.

Administrative User Account:

  • An Administrative user is a user, who has access to the Settings and Administration features but has no access to any of the customer engagement functionality.
  • Since the administrative user does not have access to customer data and any of the customer engagement functionalities, it does not require a Dynamics 365 (online) license.
  • To create an ‘Administrative User’
    • Create a User in Office 365; (Admin Center -> Users -> Active users -> Add a user)
  • User2
    • Assign a Dynamics 365 license under ‘Product licenses’ tab.
  • User3
    • Go to D365 application and open the User record
    • On the User form, under ‘Administration’ tab, ‘Client Access License (CAL) Information’ section and select “Administrative” for Access Mode.
  • User1
    • Final step is, remove the Dynamics 365 license of the User from Office 365, so that you can free the license and still the User can login to the application as ‘Administrative’

Non-interactive User Account:

  • Non-interactive user is not a physical User and It is used for programmatic access to and from Dynamics 365 between applications.
  • Non-interactive user let applications (i.e., Consoles, SSIS packages or ERP connector etc.) authenticate and access Dynamics 365 (online), without requiring a Dynamics 365 (online) license.
  • Creation of Non-interactive user account is same as Administrative User Account, except setting the Access Mode to ‘Non-interactive’
  • There is a limit of five non-interactive user accounts

Application User Account:

  • ‘Application User’ is used while establishing server-to-server (S2S) authentication
  • ‘Application User’ with conjunction of Azure Active Directory (Azure AD) will establish S2S authentication.
  • ‘Application User’ does not consume license.
  • Application users are created with a non-interactive user account, however they are not counted towards the 5 non-interactive user accounts limit.

Stub User:

  • Stub user cannot log in, cannot be enabled, and cannot be synchronized to Office 365 and will not consume license.
  • Stub Users are designed for records that have been imported that refer to this user but the user does not exist in Dynamics 365 (online).
  • Stub users are user records that are created in Dynamics 365 using Data Import or using the Create or Create Requests methods of the SDK.

Licensed User:

  • Licensed user is an User whom gets created in O365 with license and synced to D365.
  • Licensed users must be assigned at least one Dynamics 365 security role to access Dynamics 365 (online).
  • The service does not allow access to users who do not have at least one security role.
  • Removing all security roles from the user prevents the user from signing into and accessing Dynamics 365 (online). However, it doesn’t remove the license from the user.

Refer article for more details.

🙂

 

D365 – Unified Interface – Create an App and Grant App access to a Security Role

August 2, 2018 1 comment

In this article, I am going to provide steps to create new App and how to grant the App access to a particular Security Role.

Prerequisite to create App:

User must have the following privileges to create App:

  • Create, Read, and Write privileges for the “App” entity
  • Read and Write privileges for the “Customizations” entity
  • Read privileges for the “Solution” entity

Steps to create App:

  • From your Dynamics Application, go to Settings -> My Apps -> Create new App
  • You will be redirected to “Create a New App” window
  • In this example, I am going to use “Existing Solution” to add the App (Note: If any site map is available for the selected solution, the Select Sitemap drop-down list will appear when you clicked ‘Next’.)
  • Select the “Client” (Web/Unified Interface)
    • Web: This is the classic Dynamics 365 web browser client.
    • Unified Interface: This is the newer responsive web browser client that has a similar interface across PC and mobile devices.

App1

  • Click ‘Next’ to select the ‘Solution’
    • Note: ‘Next’ button will be available only if you select ‘Use existing solution to create the App’

App2

  • Click ‘Done’

Add components to the ‘App”:

  • Next is add the components (i.e., Entities, Dashboard, etc..) to ‘App’
  • In this example, I am adding ‘Account’, ‘Contact’ entities to the Sitemap

App3

  • Once you add all components, click on ‘Save’ and then ‘Publish’

Publish The ‘App’:

  • Once you create the App, next step is to ‘Publish’ so that it will be available for the respective users.
  • Go to Settings -> My Apps -> Apps Being Edited
  • Pick your App and click on and then click ‘Publish’

App4

  • Post ‘Publish’, App will be available under ‘Published Apps’ section

Grant App access to a Security Role:

Lets grant the access to Users who has ‘Sales Person’ security role.

  • Select your App from Settings -> My Apps -> Published Apps
  • Click on and then click ‘Manage Roles’

App5

  • Under the ‘Roles’ section, pick the ‘Security Role’ which you would like to grant App access to.

App6

Troubleshooting steps If App is not accessible:

  • Once you grant App access to a security role and if the App is not accessible, make sure the ‘Security Role’ has ‘Read’ privilege on ‘App‘ entity

App7

Package/Delete an app:

  • ‘App’ can be added as Solution component and can be moved between Dynamics applications
  • To delete the ‘App’, navigate to Solution -> Components ->Apps, select the App and click ‘Delete’

App8

🙂

Dynamics 365 – Using WebHooks to post data from Plugin to Azure Function

In my previous articles, I detailed the steps to create ‘Azure Functions’ and executing D365 SDK messages from ‘Azure Function’.

In this article, lets see how we fulfill Integration requirements using WebHooks model by submitting data to external WebAPIs and Services from D365.

What is a WebHook:

  • Webhooks is a lightweight HTTP pattern for connecting Web APIs and services with a publish/subscribe model.
  • Webhook senders notify receivers about events by making requests to receiver endpoints with some information about the events.

In this article, I am going to send data from Dynamics Plug-in to Azure Function using WebHooks model. So Plug-in acts as Webhook Sender and Azure Function acts as Receiver.

Below are the steps to create Azure Function and call Function from Plug-in by passing data.

Steps to create Azure Function:

  • Refer Create Azure Function article to create Azure Function Apps.
  • Create a new ‘Azure Function’ of type ‘Generic webhook’

wh1

  • Add below logic to Azure function which captures and logs the content posted from Plug-in

wh2

Get Azure Function URL:

Copy the ‘Azure Function’ URL along with key which will be used to communicate from Plugin.

  • Click on ‘Get function URL’ link and click ‘Copy’ to copy the URL

wh3

  • URL will have 3 parts
    • Endpoint URL
    • Code
    • ClientId
  • We would use only below 2 highlighted values while registering Plug-in.

wh4

Registering a WebHook:

  • Connect to Dynamics instance from Plug-in Registration tool
  • Click on ‘Register New Web Hook’

wh5

  • In the ‘WebHook Reistration’ page
    • Set ‘Endpoint URL’ as the ‘Endpoint URL’ value copied from ‘Azure Function URL’
    • Click ‘Add Property’
      • Set ‘Key’ as ‘x-functions-key’
      • Set ‘Values’ as ‘Code’ copied from ‘Azure Function URL’

wh6

Register Plug-in Step on WebHook

  • Register a Plug-in step on WebHook assembly

wh7

  • Create a step on ‘PostAccountCreation’

wh8

Test the WebHook:

  • Create an Account from D365
  • Check the Logs in Azure Function’s ‘Logs’ tab

🙂

 

Categories: Azure, CRM Tags: , ,