Advertisements

Archive

Archive for the ‘CRM’ Category

Dynamics Portals – Add Download feature to the Forms

September 22, 2019 Leave a comment

In my previous article I’ve explained the Portal styling using Metadata option.

This article is the extension to the styling article, where I will explain how to add ‘Download’ feature to the Form.

I am going to use the ‘Registration’ form as an example, and will see the steps to add a ‘Download’ link to a word document.

Add the Document as a Web File:

  • As a first step, create a new ‘Web File’ and note down the ‘Partial URL’.

Dld_1

  • Next, add the document which you want your Portal user to download from Portal, as a Web File attachment under notes.

Dld_2

Design HTML with Download link:

  • Design the HTML page as per your requirement.
  • For the download link, add a <a> tag with an ID.
  • Add a JScript function, to read the <a> tag by ID and set the web file URL in the document.ready() event.

Dld_5

  • Add the HTML to the Portal entity forms ‘Metadata’ record.

Lab_7

  • Browse the Portal form and you should see the document link, which opens the document on click.

Dld_3

Note:

  • You can only add the allowable file types as the ‘Web File’ attachment.
  • To change the allowable file types, navigate to ‘Settings -> Administration -> System Settings’ and modify in the ‘Set blocked file…‘ field.

Dld_4

🙂

Advertisements

[Dynamics CE] Configure and automate Document Template generation

September 21, 2019 Leave a comment

In this article, lets see how to configure ‘Document Template’ on ‘Contact’ entity and automate the template the generation using OOB ‘SetWordTemplate‘ Action from  a Workflow.

Configuring ‘Document Template’:

  • Form Dynamics application, navigate to ‘Settings -> Templates -> Document Templates’.
  • Create a new Template and choose ‘Filter by entity’ as ‘Contact’.

DT_1

  • Click on ‘Select Entity’.
  • In the next screen, select the Relationships, if you need to render related entity data in the Template.

DT_2

  • Click ‘Download Template’
  • Save and Open the downloaded word document.
  • From word Ribbon, Click on ‘Developer’ tab, ‘XML Mapping’ and from the drop down, select the option as below:

DT_3

  • Next compose the content and add the Contact/Related entity fields as required.
  • Save the document and its time to upload the configured Template.
  • Form ‘Settings -> Templates -> Document Templates’, click on ‘UPLOAD TEMPLATE’
  • Click ‘browse’ and attach the configured Word Template.

DT_4

  • Click ‘Upload’
  • In the next screen, you can change the ‘Name’ and ‘Description’ and click ‘Save’

DT_5

Generate Document Template Manually:

As we completed the ‘Document Template’ configuration, now lets see how to manually generate the ‘Document Template’

  • Open the Contact record.
  • From the menu, select ‘Word Templates’ and pick our Template from the list.

DT_6

  • Application will generate a Word Document as below:

DT_7

Automate Document Template Generation:

Sometimes we would need to generate the ‘Document Template’ , based on the business rules. As an example, If a ‘Contact’ record created with ‘Company Name’ field, generate the Document Template. Below are the steps to automate using ‘Workflows’

  • Navigate to Settings -> Processes
  • Create a new ‘Workflow’ by selecting ‘Contact’ as Entity.

DT_8

  • Under the ‘Steps’ section, select ‘Perform Action’

DT_12

  • Select ‘SetWordTemplate‘ action and click on ‘Set Properties’ and map our ‘Word Template’, as shown below.

DT_9

  • Activate the Workflow.

Test the automated Document Template Generation:

You can invoke this workflow based on your business requirements. You can also configure this as ‘Child process’ and trigger from other workflows.

For this article, lets trigger this as ‘On-demand Workflow’

  • Open the ‘Contact’ record.
  • From the sitemap menu, click on ‘Run Workflow’ and run the ‘Workflow’ as below

DT_10

  • Refresh the Contact record and under ‘Notes’ tab, you should see the generated ‘Word Document’. Note that, as its a “Background Workflow”, the process may take few seconds.

DT_11

Notes:

  • “Document Templates’ cannot be included in Solutions to move to other environments.
  • Use Document Templates Mover tool to move templates to other environments.
  • This tool keeps the ‘Document Template’ GUID constant across the environments which means you don’t need fix the workflow’s with ‘Document Template’ lookup resolution issues.

🙂

 

 

 

‘Address Suggestions’ in Portals using Esri ArcGIS

September 15, 2019 Leave a comment

In our Dynamics Portals, we got a requirement to show ‘Address Suggestions’ as and when the end user start typing the address.

We implemented the solution by consuming the Esri ArcGIS mapping service, from our Portal’s web page.

ESRI_1

‘Entity Form’ with Address Suggestions

In this article lets see how to implement this at a high level.

What is ESRI ArcGIS?

  • Its a cloud based mapping and analytics platform.

ESRI_3

  • For our ‘Address Suggestions’ requirement, we have consumed ESRI ArcGIS’s World Geocoding Service
  • World Geocoding Service:
    • Its part of ESRI ArcGIS.
    • This Service finds addresses and places in all supported countries from a single endpoint.
    • The service can find point locations of addresses, business names, and so on.

Steps to fetch ‘Address Suggestions’:

  • To fetch the ‘Address Suggestions’, we have used findAddressCandidates operation of ‘World Geocoding Service’.
  • findAddressCandidates operation is REST based and takes ‘Input address’ as parameter.
  • As an example, to fetch the ‘Microsoft Office’ addresses in ‘Redmond’ the REST URL would be as follows:

https://geocode.arcgis.com/arcgis/rest/services/World/GeocodeServer/findAddressCandidates?SingleLine=Microsoft+Redmond&sourceCountry=USA&category=&outFields=*&forStorage=false&f=pjson

ESRI_2

  • In the above URL,
    • ‘findAddressCandidates’ –  Operation name.
    • ‘SingleLine’ – Parameter which you need to pass address you are looking for (i.e., Microsoft+Redmond). Use + symbol to combine the words.
    • ‘sourceCountry’ – Optional parameter. if provide, results will be specific to provided country code.
  • Below is the sample script to call the service from Portal Web Page/Entity Form/ Web Templates.

function GetAddressrecommendations(address) {
var url = https://geocode.arcgis.com/arcgis/rest/services/World/GeocodeServer/findAddressCandidates?SingleLine=”+address+”&category=&outFields=*&forStorage=false&f=pjson;
// To limit the address to ‘United States’ country uncomment below line
// url += “&sourceCountry=USA”;

var xhr = createCORSRequest(“GET”, url);
if (!xhr) {
throw new Error(“CORS not supported”);
}
xhr.onload = function () {
var text = xhr.responseText;
// Success and add logic to Parse the Response.
};
xhr.onerror = function () {
alert(“Unable to fetch addresses.”);
};
xhr.send();
}

function createCORSRequest(method, url) {
var xhr = new XMLHttpRequest();
if (“withCredentials” in xhr) {
xhr.open(method, url, true);
} else if (typeof XDomainRequest != “undefined”) {
xhr = new XDomainRequest();
xhr.open(method, url);
} else {
xhr = null;
}
return xhr;
}

How to call the method?

  • Call the GetAddressrecommendations function by passing the address you are looking for
    • GetAddressrecommendations(‘Microsoft+Redmond’)

Notes:

  • Esri ArcGis platform provides both hosted GIS services and a portal with a web UI and APIs for publishing, sharing, and managing content, maps, applications, and users.
  • It has both Free and Paid services. Read the documentation before making the decision.

🙂

[Code Snippet] Dynamics Post Assign Plugin

This article is a response to one of the blog questions. 

Below is the code snippet for Post Assign (i.e., Ownership change) plug-in.

In the ‘Post Assign’ plug-in you get 2

  • Current record as ‘Entity Reference’ in ‘Target‘ attribute.
  • Records new Owner (i.e., Owner or Team) in the ‘Assignee‘ attribute.

EntityReference entRefCurrentRecord = null;
EntityReference entRefAssignee = null;

// Get current record as Entity Reference
if ((context.InputParameters.Contains(“Target”)) && (context.InputParameters[“Target”] is EntityReference))
{
entRefCurrentRecord = (EntityReference)context.InputParameters[“Target“];
}

// Get User/Team whom the record assigned to from ‘Assignee’ property of Context
if ((context.InputParameters.Contains(“Assignee”)) && (context.InputParameters[“Assignee”] is EntityReference))
{
entRefAssignee = (EntityReference)context.InputParameters[“Assignee“];
}

// Write your business logic

  • You might want to register Pre/Post images on the Plug-in step, to read other attributes of the record.

🙂

Categories: CRM Tags: , ,

Dynamics/ADX Portals – Create Notes using SDK

As part of an integration requirement, we had to create ‘Notes’ (i.e., Annotation) with attachment using SDK.

Key Notes:

  • ‘Subject’ and ‘Notetext’ field values of Portal Notes follows a specific pattern than that of Dynamics.  Values must be set as follows:
    • SubjectNote created on {DateTime.Now.ToString()} by {Portal User Name} [contact:{PortalUserGUID}]
      • If the Portal user name is ‘Rajeev P’ and Portal user GUID(i.e.,Contact record’s GUID) is ‘2510ae27-7289-e911-a958-001dd800d97c’, Subject will be Note created on {DateTime.Now.ToString()} by Rajeev P [contact:2510ae27-7289-e911-a958-001dd800d97c]
    • Notetext*WEB*
  • If you don’t pass Portal User’s GUID in ‘Subject’ field, Portal shows the Notes record created by as User whom the Portal was configured.

Code to create Annotation:

Below is the code snippet

var noteSubject = “Note created on {DateTime.Now.ToString()} by Rajeev P [contact:2510ae27-7289-e911-a958-001dd800d97c]“;

var entAnnotation = new Entity(“annotation”);
entAnnotation[“subject“] = noteSubject;
entAnnotation[“notetext“] = “*WEB*”;
entAnnotation[“filename”] = {File_name}; // Set FileName
entAnnotation[“documentbody”] = {Base64String}; // Pass document body in Base64 format
entAnnotation[“isdocument”] = true;
entAnnotation.Attributes[“objectid”] = new EntityReference({RegardingSchemaName}, {RegardingGuid}); // Set Schema and GUID
entAnnotation.Attributes[“objecttypecode”] = {RegardingSchemaName}; // Set Schema

var noteId = crmService.Create(entAnnotation);

  • Note : Replace values in {} with actual values.

🙂

 

 

[PowerApps Portal (preview)] Build your first portal

PowerApps Portalsprovides ability to build low-code, responsive websites which allow external users to interact with the data stored in the Common Data Service.

Refer article for introduction. PowerApps Portals are in Preview now and lets see how to get started with a simple portal.

Perquisites:

Steps to build your first Portal:

  • Login to PowerApps maker Portal
  • Pick the right ‘Environment’. Refer ‘Notes’ section below to know more about ‘Environments’.
  • Click on ‘Portal from blank (preview)’ link.

PAPP_Portal_15

  • In the pop-up, fill ‘Name’, ‘Address’ and ‘Language’ and click ‘Create’.

PAPP_Portal_2

  • Portal provisioning takes time and you will be notified once done.

PAPP_Portal_5

  • Post provisioning, click on ‘Edit’ which will redirect you to Portal editor.

PAPP_Portal_16

  • You get pre configured ‘Home’ page and ‘Child Pages’.
  • To add a new Page,
    • Either click on ‘+New page’ from ribbon
    • Or Right Click , ‘Home’ and add a New Page.

PAPP_Portal_6

  • I have added a new ‘Accounts’ page and filled the details on the right side ‘Component’ panel.
  • To create a new ‘Account’ form, click on ‘Form’ and choose Entity, Form and Mode from the ‘Component’ panel.

PAPP_Portal_8

  • To add a new ‘Entity List’ control, click on ‘List’ and on the right hand side, select ‘Entity’ and ‘Views’
    • Note: In the screen below, I’ve added an existing ‘List’. The properties are same for new ‘List’ as well.

PAPP_Portal_7

  • To map the Account ‘Form’ with ‘List’, set properties as below

PAPP_Portal_9.PNG

  • At any point of time, to view the changes, click on  ‘Browse website’ on top right corner.
  • Home Screen

PAPP_Portal_13.PNG

  • Accounts Screen

PAPP_Portal_14

Notes:

  • To use the Dynamics CE entities, you have to select the CE ‘Environment’ in your maker portal, before the start of Portal creation.
    • A ‘default’ environment gets created by default. If you pick ‘default’ environment, you will need to create a new Environment with CDS database.

PAPP_Portal_17

PAPP_Portal_18

New Environment

  • We can still create Portal from the ‘Dynamics Admin Center’.

PAPP_Portal_3

  • PowerApps portal got ‘.powerappsportals.com’ as domain and regular portal will be of ‘.microsoftportals.com’ domain.

PAPP_Portal_4

  • You can still create/update portal components (i.e., Entity List, Forms, Web Templates) from Dynamics web application.
  • Clear cache using ‘/_service\about‘ is still available in PowerApps portal.

PAPP_Portal_10

🙂