Advertisements

Archive

Archive for the ‘CRM’ Category

‘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.

🙂

Advertisements

[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

🙂

 

 

Dynamics CE – Issue while updating ‘Annotation’ record using SDK

Other day, we encountered following error in our plug-in, which has the logic to retrieve and update the ‘objectid’ field (i.e., Associated record) of Annotation record.

‘new_myentity’ with ID XXX-XXXX-XXXX-XXX does not exists

Below is the plug-in code:

var entAnnotation=new Entity(“annotation”);
entAnnotation.Attributes[“objectid”] = new EntityReference(“new_myentity”,”{GUID}”);
crmService.Update(entAnnotation);

We are trying to update ‘objectid’ and from the error, its clear that Object ID (i.e.,GUID) of the ‘new_myentity’ entity does not exists in the application.

But we know that the GUID is of a valid ‘new_myentity’ entity, as that was retrieved using ‘Query Expression’ in previous plug-in statement.

Reason and Fix:

  • We must also set ‘objecttypecode’ field as the schema name of the ‘objectid’ of the Annotation record.
  • In our case, its ‘new_myentity’.
  • Below is the code of Annotation update setting ‘objecttypecode’ field.

var entAnnotation=new Entity(“annotation”);
entAnnotation.Attributes[“objectid”] = new EntityReference(“new_myentity“,”{GUID}”);
entAnnotation.Attributes[“objecttypecode”] = “new_myentity“;
crmService.Update(entAnnotation);

Issue was annoying and took sometime to troubleshoot and find the actual reason.

🙂

Dynamics Portals – Web Templates – ‘$ is not defined’ Error

Other day, I was getting ‘$ is not defined’ script error during my ‘Web Template’ load.

Portal_$_1

From the error, its clear that jQuery file reference was missing in Web Template.

The Web Template has a HTML with Liquid Template and script using jQuery and was rendering with no issues an hour ago and there were no changes made to the Web Template content.

Reason and Fix:

  • ‘Use Website Header and Footer’ field was unchecked in ‘Page Template’ which was causing the issue.

Portal_$_2

  • jQuery file would be implicitly available to the ‘Web Template’ when ‘Use Website Header and Footer’ field is checked on ‘Page Template’.
  • Save the Page Template
  • Clear the portal Cache and issue should be fixed.

🙂

 

 

 

PowerApps Portal – Intro

June 14, 2019 1 comment

Those who are familiar with ADX Portals which later acquired by Microsoft and came up with ‘Dynamics Portals’ SaaS offering, ‘PowerApps’ Portal is the next evolution.

  • With PowerApps Portals, Microsoft merging the capabilities offered by Dynamics 365 Customer Engagement portals in to PowerApps Portals.
  • PowerApps Portals provides the ability to build low-code, responsive websites which allow external users to interact with the data stored in the Common Data Service (CDS).
  • PowerApps Portals will seamlessly integrate with Microsoft services like Power BI embed, Microsoft Flow, Microsoft SharePoint, Azure Blob Storage, Azure AD B2C, and Azure Application Insights to enhance your portal with rich content and provide a personalized experience to your customers.
  • All the components of Dynamics CE portals (i.e., Entity Forms, Web Templates, Web Forms,etc…) will be continued to available in PowerApps Portals.
  • PowerApps portal uses the same ‘Liquid Template’ scripting conventions of Dynamics CE Portals.

How to get started?

  • General availability of PowerApps Portal will from July 2019.
  • A new App type called “Portal” will be available directly from PowerApps.

PowerApps Portal

  • You can subscribe here to be informed about the Public Preview availability.

Whats the upgrade path for existing Dynamics 365 CE Portals?

  • All the existing Dynamics 365 CE portals will auto upgrade to PowerApps portals in coming months.

🙂