Advertisements

Archive

Archive for September, 2019

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.

🙂