System Jobs monitoring using Flow

  MonitoringMain

System Jobs

AsyncOperation or System Job is an important Dynamcis 365 system entity. Usually we don’t create its records, rather they are created automatically. A record represents a single execution of an asynchronous resource. They include important details about asynchronous operation like name of resource, status (waiting for resources, waiting, in progress, pausing, cancelling, succeeded, failed and cancelled), time of execution and error details in case thing go wrong. We can view system jobs by navigating to  Settings > System Jobs.  There are 68 (or more) types of system jobs but as a CRM  user commonly we use the following asynchronous operations:

  • System Event (Asynchronous Plugin)
  • Workflow
  • Bulk Delete
  • Bulk Email
  • Import
  • Rollup Field

A few system related types are:

  • Index Management
  • Database Tuning
  • Collect Organization Storage Size
  • Calculate Organization Maximum Storage Size
  • Storage limit notification

For complete details of System Job types see “OperationType” attribute in “AsyncOperation” (System Job) entity.

Why we need to monitor System Jobs?

It is quite common to use asynchronous workflow, asynchronous plugin, rollup field, bulk delete or import features. Since they are asynchronous, most of the time we will not get a notification if they fail until we go and check status.

New To Flow ?

If you are new to Flow, in the following post I have discussed basics of Flow. Please go through it if you need more understanding of Flow basics:

https://crmtechie.com/2018/05/24/create-contact-from-received-email-using-flow/

About demo

We can navigate and see status when we need. It is useful but sort of manual. It will be good to have a piece of automation which may periodically inform power user or admin about failed jobs. In this demo I will use Flow to send a scheduled email (once a day in this demo but of course it can be configured as per requirement), listing the status of failed jobs. This approach can be used in different scenarios.

This solution works in the following 4 steps:

  1. At a scheduled time flow execution starts
  2. Filter, sort and read system job records from CRM
  3. Create HTML table from CRM records
  4. Finally send HTML table in an email 🙂

Let’s begin:

Step 1:

  • Sign in to https://flow.microsoft.com/ and click “My flows”
  • In next page click “Create from blank”
  • Click “Create from blank” again in next screen 🙂
  • Select or search “Schedule” from connectors

Monitoring1Monitoring2

Monitoring3

Monitoring4

  •  Click “Schedule – Recurrence” and later configure time zone and start time. I m using “1” as “Interval” and “Day” as “Frequency”

Monitoring5

  • From “Show advanced options”, select time zone and start time. I m using “(UTC + 10:00) Canberra, Melbourne, Sydney” as time zone and  “2018-06-08T10:15:00Z” as the start time.

Monitoring6

Step 2:

  • Click “+ Add New step” and then “Add an action”
  • Search “Dynamics” in the list of connectors and actions and select “Dynamics 365”
  • From actions select “Dynamics 365 – List records (Preview)

Monitoring7

Monitoring8

  • Click Menu ( ), and then sign in to your Dynamics 365 instance by pressing “+ Add new connection”
  • From “Show advanced options” do the following configurations:
    • Select your Organization Name
    • “System Jobs”  in “Entity Name” field
    • “statuscode eq 31” in Filter Query (for details see this)
    • “startedon desc, createdon desc” in “Order By” field

Monitoring9

Step 3:

  • Search and add new action of type “Data Operations – HTML table”
  • Click “From” field and select “value” from Dynamic content window

Monitoring10Monitoring11

  • Clicking “Show advanced options” to add the data columns
  • Enter heading, click Value part and select column from “List records” window
  • For better spacing between columns, add an empty column between every two columns and use a character or combination (| or . or : or ::) in header
  • I have used System Job Type, System Job Name, Status Reason Label and Created On columns for reporting

Monitoring12

Step 4:

  • Search send email and add Outlook or Gmail connector
  • From actions select send an email
  • From ( … ) menu sign in and  add connection to your mail box if you are not already connected

Monitoring13

  • Enter “To” email address and subject
  • Click in “Body” and from Dynamic content select “Output”

Monitoring14

  • From “Show advanced options” select “Yes” for “Is HTML” field
  • Save
  • Wait for execution as per time entered or from top right corner click “Test” for testing execution.

Monitoring15

Using Flow for monitoring can be used in interesting scenarios like scheduled monitoring, monitoring a particular async resource or type of resources and even to monitor progress while execution.

I hope you like this solution and Flow overall.

Enjoy your day of 365 life.

About Me 🙂

I m an IT consultant working in Melbourne Australia. I solve business problems using Microsoft technologies (Dynamics 365, Office 365, Azure, Flow, Power Apps, Power BI). I m involved in community activities and I blog at http://www.crmtechie.com/

I love to get connected with people working in IT, providing solutions or who just like Microsoft technologies. To get in touch please follow my blog, and connect through Linkedin, Twitter or Facebook

Blog: http://www.crmtechie.com/

Twitter: @YawerIqbal

Linkedin: YawerIqbal

Facebook: Yawer.Iqbal

Create contact from received Email using Flow

EmailToCRMUsingFlow2 copy

Last week in a meeting client explained requirement:

“.. we receive emails in a mail box, and we manually create contacts in CRM using sender name and address for further processing, we want to automate this.. .”

This task was going to extend existing system functionality but there was no existing code to reuse or modify and of course expectation was to deliver this soon. So it was a perfect case to use Microsoft Business Application Platform. In this post I will explain how easy it was to provide solution using Flow.

New to Flow ?

Flow is part of Business Application Platform and it is latest service from Microsoft to create automated workflow. It is intended for business and power users so most of the time tasks can be performed without writing a single line of code. Some of its cool features are:

  1. It integrates different systems and applications
  2. Create workflow and automation tasks
  3. Transfer data between systems
  4. Can be used easily with a bunch of other Microsoft technologies

To get started first step is to sign up at flow.microsoft.com. Currently there is a basic “Flow Free” plan which is free, for more details about pricing see this.

How Flow Works ?

There are three basic components in Flow which are connector, trigger and action.

Connector is used to connect to source and target system. A few examples of connectors are Dynamics 365, OneDrive, Gmail, Twitter, Excel, Azure Storage, Oracle, DB2, RSS, Eventbrite or Youtube. At the time almost 227 connectors are available and hopefully this number will increase.

A trigger is an event that occurs inside the connector. For example with SharePoint a few triggers are:

  • File creation
  • Deletion of a file
  • File modification

Similarly a trigger with Gmail is when a new email arrives. A connector can have multiple triggers and in a flow usually we chose a trigger which start execution of flow.

After selecting trigger normally next step will be to chose target system or service (again using connector). Similar to triggers with source connector, a target connector may have multiple associated actions to chose from. For example Office 365 Outlook has:

  • Create Contact
  • Send Email
  • Create Event

By choosing an action we tell what should happen to target system or server. Good thing is we can chose multiple actions which will be performed one by one. For example we can create a flow which on receiving an email will send a sms, create a file in Sharepoint and also create record in Dynamics 365.

Solution

ETOC1

ETOC2

CCFEF3

  • Click menu and sign in using your Gmail account using “+ Add new connection”

CCFEF4

  • Click “add an action”
  • Type Dynamics and then click “Dynamics 365 – Create a new record”

CCFEF5

  • Click menu and then from “+ Add new connection” sign in to Dynamics 365 account
  • Select your Dynamics 365 organization name in “Organization Name” field
  • Select ‘Contact’ as entity from “Entity Name” field
  • After selecting entity name more fields will be loaded in “Create a new record” form

CCFEF7

CCFEF8

CCFEF8.1.PNG

  • In form click “Last Name” and then from dynamic content list select “Sender’s Name”
  • Similarly select “Email” in create a new record form and then from dynamic content “From” email address
  • Press Save button to save the Flow and that is all !

CCFEF9

CCFEF10

CCFEF11

  • Send email to linked account and after 3-4 second verify new contact created in Dynamics 365 from email received.
  • Click “My flows” link and then click flow listed to verify its execution was successful

CCFEF12

CCFEF13

Note:

This demo was created using Gmail, but for Outlook, “Outlook.com” and “Office 365 Outlook” two connectors are available. One catch though is at the time they do not offer senders name as dynamic content. A solution can be to redirect Outlook emails to a Gmail box and configure Gmail to create a contact in Dynamics 365.

About Me 🙂

I m an IT consultant working in Melbourne Australia. I solve business problems using Microsoft technologies (Dynamics 365, Office 365, Azure, Flow, Power Apps, Power BI). I m involved in community activities and I blog at http://www.crmtechie.com/

I love to get connected with people working in IT, providing solutions or who just like Microsoft technologies. To get in touch please follow my blog, and connect through Linkedin, Twitter or Facebook

Blog: http://www.crmtechie.com/

Twitter: @YawerIqbal

Linkedin: YawerIqbal

Facebook: Yawer.Iqbal

Unexpected exception from plug-in (Execute): System.MissingMethodException: Method not found: ‘!!0[] System.Array.Empty()’.

For a demo I was writing a workflow activity and got the error:

Unexpected exception from plug-in (Execute): WorkFlowComponents.DeleteUnwantedPotentialLeads: System.MissingMethodException: Method not found: '!!0[] System.Array.Empty()'.

It was happening becasue my assembly version was not supported by Dynamics 365. As per this document Dynamcis 365 supports .Net Framework 4.5.2.

Corrected target .Net framework, redeployed assembly and same code started working as expected.

Hope it will help.

Ftp to CRM using Azure Function

FTPTOCRM

New to Azure Function?

Function is serverless offering form Azure. Serverless computing is a way to write code without need to manage infrastructure, application dependencies and other required resources. Even for scaling Azure will take care of them. Once we know the environment using Function is easy, login to Azure portal write or deploy code and start using it.

An Azure function is simply a function written in C#, Java, JavaScript, F#, Python or PHP. A function can be executed manually or scheduled to run automatically. The third way to execute a function is through triggers. A trigger can be another Azure service or something which has no link with Azure. Some Azure services which can trigger a function are Cosmos DB, Event Hubs, App Service, Storage queues, blobs, Service Bus queues or topics. Functions are also available for Logic Apps, Power Apps, Microsoft Flow and outside Azure over HTTP.

About Demo

This function will be scheduled to run once in 24 hours. From ftp server it will read a CSV file (data for lead entity) and pass it to CRM. Functions can be coded and published from Visual Studio or directly in Azure portal, for this demo I will use later approach.

FtpFun_0CreatefunApp

Create Function App and Function

To create a function we need to create a function app. If you don’t want to use existing resource group and storage feel free to create new.

Open function app and add a function in it:


In Schedule add 0 0 12 * * *. This cron expression will trigger this function in midnight at 12 O’clock. See this for more details about cron expression.

App Settings

Let’s add CRM connection string, FTP URL and credentials as application settings to avoid hard coding.

Sample of application settings:

Key Value Comments
FtpId UserId  Ftp account user id
FtpPassword P@ssword  Ftp account password
FtpAddress  ftp://ftp.domain.com/full.csv Ftp address with file name
Connectionstring AuthType = Office365; Url = https://crminstace.crm6.dynamics.com/;

UserName=crmuser@domain.com;

Password=crmP@ssword

This is example with Dynamics 365, no need to surround with single or double quote.

Code

FtpFun_10CreatefunApp

using System;
using System.Configuration;
using System.IO;
using System.Net;
using Microsoft.Azure.WebJobs;
using Microsoft.Azure.WebJobs.Host;
using Microsoft.Xrm.Sdk;
using Microsoft.Xrm.Tooling.Connector;
public static void Run(TimerInfo myTimer, TraceWriter log)
{
log.Info($”Execution Started. : {DateTime.Now} “);
Stream fileStream = null;
string[] fileContentToWriteToCRM;
IOrganizationService org;
string ftpId = ConfigurationManager.AppSettings[“Ftpid”].ToString();
string ftpAddress = ConfigurationManager.AppSettings[“ftpAddress”].ToString();
string ftpPassword = ConfigurationManager.AppSettings[“ftpPassword”].ToString();
#region Read Ftp File(s)
FtpWebRequest ftpReq = (System.Net.FtpWebRequest)System.Net.FtpWebRequest.Create(ftpAddress);
ftpReq.Credentials = new NetworkCredential(ftpId, ftpPassword);
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
ftpReq.EnableSsl = false;
WebResponse tmpRes = ftpReq.GetResponse();
fileStream = tmpRes.GetResponseStream();
#endregion
#region ProcessData
TextReader tmpReader = new StreamReader(fileStream);
var txtData = tmpReader.ReadToEnd();
fileContentToWriteToCRM = txtData.Split(new string[] { “\r\n” }, StringSplitOptions.RemoveEmptyEntries);
#endregion
#region CRM Data Posting
string connectionstring = ConfigurationManager.AppSettings[“connectionstring”];
CrmServiceClient conn = new Microsoft.Xrm.Tooling.Connector.CrmServiceClient(connectionstring);
org = (IOrganizationService)conn.OrganizationWebProxyClient != null ? (IOrganizationService)conn.OrganizationWebProxyClient : (IOrganizationService)conn.OrganizationServiceProxy;
log.Info($”CRM connection established”);
log.Info($”Looping to move data to CRM”);
foreach (var row in fileContentToWriteToCRM)
{
var rowvalues = row.Split(‘,’);
Entity lead = new Entity(“lead”);
lead.Attributes[“subject”] = rowvalues[0].ToString();
lead.Attributes[“firstname”] = rowvalues[1].ToString();
lead.Attributes[“lastname”] = rowvalues[2].ToString();
var id = org.Create(lead);
log.Info($”Lead created in CRM with GUID : {id} “);
}
log.Info($”Loop Ended moved all data to CRM “);
#endregion
}

Adding Dependencies

Since code use assemblies from CRM SDK, we will add these to our code. With Azure Function it is achieved using project.json file. Add project.json file if it is not already there and then add NuGet packages in it.

FtpFun_11CreatefunApp

FtpFun_12CreatefunApp

{
“frameworks”: {
“net46”:{
“dependencies”: {
“Microsoft.CrmSdk.CoreAssemblies”: “9.0.0.0”,
“Microsoft.CrmSdk.XrmTooling.CoreAssembly”:”9.0.0.7″
}
}
}
}
Let’s save it, run the function if it is not already running and see how we go.

Result

FtpFun_13CreateFunApp

Hope this help, enjoy your 365 day 🙂

Cheers

About Me 🙂

I m an IT consultant working in Melbourne Australia. I solve business problems using Microsoft technologies (Dynamics 365, Office 365, Azure, Flow, Power Apps, Power BI). I m involved in community activities and I blog at http://www.crmtechie.com/

I love to get connected with people working in IT, providing solutions or who just like Microsoft technologies. To get in touch please follow my blog, and connect through Linkedin, Twitter or Facebook

Blog: http://www.crmtechie.com/

Twitter: @YawerIqbal

Linkedin: YawerIqbal

Facebook: Yawer.Iqbal

{Quick Tip} collapse or expand form sections without code

The trick is in form design mode the way we left sections, save and publish will be the state of form when they load. We can choose to collapse or expand all sections or go for a combination. I have not tested in previous versions but it works in 365 🙂

Enjoy your 365 day 🙂

#exand-or-collapse-crm-form, #how-to-expand-or-collapse-crm-form

Browser extensions for Dynamics CRM

Browser extensions are great software components which increase productivity and let browser do things which they can’t otherwise.

For Dynamics CRM a few add-ons are available which do fantastic things for CRM developers, testers and power users. This post will review these extensions and their features.

Dynamics CRM Power Pane

PowerPane

Dyanamics CRM Power Pane is developed by Onur Menal (CRM technical consultant from Turkey) and is available for Chrome and Firefox.

Its features are classified as:

  • Record Actions
  • Form Actions
  • Navigation.

For any record, with a click, we can see record guid, record url, entity name and entity type id. Copying a record to clone in a new tab is another useful record action. Form actions let the user enable all fields, show hidden fields, disable value requirement, get schema names as the field label, and copy schema names in form. Other features like showing optionset or field values, highlighting the dirty field and refreshing ribbon or form are also useful form actions. Navigation section directly opens a record, entity editor, and mobile clients. Power Pane also has some performance and diagnostic features.

Level up for Dynamics CRM/365 

LevelUp

Level up for Dynamics CRM/365 is developed by Natraj Yegnaraman (MVP from Melbourne, Australia) and is available for Chrome.

Its features are categorized as:

    • Forms

  • Navigation
  • Misc

Level up has almost all major features offered by Power Pane and a good thing is it offers some unique features as well. For example ‘God Mode’ makes all mandatory fields optional, hidden fields/tabs/sections visible and read-only fields editable. Some other cool features allow refreshing all sub grids, refreshing page and turning autosave off, toggling tabs, copying and pasting lookup value, opening lookup in a new window, seeing a list of business rules and workflows in a separate tab. From navigation section, in a new tab, it can open different CRM sections. Overall I have found it very useful.

Dynamics CRM DevTools 

SnomaPartners

DevTools is offered by Sonoma Partners (Microsoft Partner from the United States) and is available for Chrome.

It has some common features of other tools (like enabling form, showing schema names, showing hidden fields, refreshing form, record properties, performance tools, user and record details etc). Unique features are the possibility to run fetchXML, list of plugin, setting focus to a field and changing field value for testing. DevTools also offers a set of performance and debugging reports.

CRM Javascript Fiddle

JSFiddle

CRM Javascript Fiddle is another tool developed by Onur Menal (developer of Dynamics CRM Power Pane) and is available for Chrome.

I have not got a chance to use it, here I m pasting its description provided by the publisher:

Run javascript codes on CRM without publish.

This extension allows you to run javascript code on Microsoft Dynamics CRM. In this way you can show hidden fields , you can enable and edit the disabled fields or you can achieve the available methods or object on web resouces of current form with “this” keyword. Such as

this.YourWebResourceFunction();

Also it provides storage support for your snippets.

Have you used or developed an extension which I have not covered in this post?  kindly comment if there is.

Please follow my blog to remain informed about upcoming posts.

Enjoy 🙂

About Me 🙂

I m an IT consultant working in Melbourne Australia. I solve business problems using Microsoft technologies (Dynamics 365, Office 365, Azure, Flow, Power Apps, Power BI). I m involved in community activities and I blog at http://www.crmtechie.com/

I love to get connected with people working in IT, providing solutions or who just like Microsoft technologies. To get in touch please follow my blog, and connect through Linkedin, Twitter or Facebook

Blog: http://www.crmtechie.com/

Twitter: @YawerIqbal

Linkedin: YawerIqbal

Facebook: Yawer.Iqbal

How to find Business Rule, Form, View, Chart, Process and Message associated with a field

Sometimes we need to know which Form, View or Chart are using a field. Similarly we may need to check which Process and Plugin message are attached to a field. All these details can be viewed easily from field’s “Show Dependencies” functionality.

Generally navigation for “Show Dependencies” will be:
(Settings > Customizations > Customize the System > Components > Entites > Entity (Select your entity)  > Field (select your field) > Show Dependencies).

This window shows useful details about some other dependent components as well like Field, Entity Relationship, Email Template, Report etc. Business Rule is exception though, to see business rules we will need to click “Business Rules” button in same window.

Hope this tip will be helpful if you were not using it.

Please like/ follow my blog for more useful posts. Please feel free to leave a message, suggestion or question if I can help.

Enjoy 🙂

 

Upgrading To Dynamics 365 ?

At Sydney CRM Saturday Greg Olsen (Dynamics 365 MVP from New Zealand) presented “What You Need To Know To Upgrade To Dynamics 365”. It was a very nice and much valuable talk. Speaker not only shared his experience but also packs of chocolates and sweets 🙂

Upgrades

It has helped me understanding planning

phase of upgrade. Luckily Greg has shared presentation and I m sharing link in this post below:

https://app.box.com/v/UpgradeToD365

Please like/ follow my blog if you found this post helpful. Feel free to leave a message, suggestion or question.

Have a very lovely weekend.

Cheers 🙂

How to view plugins deployment summary ?

Sometimes we need to know when last time a plugin was updated. This information is helpful usually before exporting assemblies from one environment to other.
In similar way few times we may need to know who updated a particular assembly last time ?

The following LINQ or Fetch Xml query will return this summary:

(from p in PluginAssemblySet
orderby p.ModifiedOn descending
select new
{
PluginName = p.Name, ModifiedOn = p.ModifiedOn.Value.ToLocalTime(),
ModifiedBy= p.ModifiedBy.Name, Role=p.ModifiedBy.LogicalName,Version=p.Version
}).Dump();

 

 

Citizen Integrator – Microsoft Flow and Dynamics 365

Yesterday at Melbourne Microsoft Dynamics 365 User Group meeting Bill Chesnut (Azure MVP) delivered a much valuable talk “Citizen Integrator – Microsoft Flow and Dynamics 365”.

From some basic to latest updates around Flow were covered. Luckily Bill has shared his talk and slides. There is slight buzz in background but it is still good.

Video:  http://www.sixpivot.com/sixpivotblog/

Slides: https://www.biztalkbill.com/wp-content/plugins/download-attachments/includes/download.php?id=9552

 

Enjoy