Understanding Client API Objects

Microsoft has provided an API facility for retrieving the data from the form directly using web-resource(JavaScript/HTML etc) which is known as Client API.

Client API helps us in many ways like:

  1. Get or set attribute values.
  2. Show and hide user interface elements.
  3. Reference multiple controls per attribute.
  4. Access multiple forms per entity.
  5. Manipulate form navigation items.
  6. Interact with the business process flow control.

Client API has 4 main objects:

  1. Execution Context
  2. Form Context
  3. Grid Context
  4. XRM object

I will be covering the two most used object in this blog which is Execution Context and Form Context.

Execution Context: executionContext defines the event (OnLoad, OnSave, OnChange) on which your code is executed. It passes the runtime information about the event which took place on the forms or grids like user information, form level information, attribute level information etc. It is used in the function as a object which gets all the necessary information from the CRM to our code . Therefore it is required to pass execution context as a first parameter inside the event handler.

function OnContactLoad(executionContext)
{
}

Form Context: formContext is a part of executionContext. It provides us an access to a form or form items using JavaScript. Before D365 v9.0 we were using XRM.Page which performed the same role as formContext. With the v9+ of CRM when XRM.Page is being deprecated hence it is always recommended to use formContext.

For accessing formContext below is the command:
var formContext = executionContext.getFormContext();

function OnContactLoad(executionContext)
{
var formContext = executionContext.getFormContext();
}

formContext contains two object:
Data object: This used to get the attributes data from the form.
Example: We have a text field on the form and we want to access the field data, then we will be using data object.
formContext.data.entity.attributes
or
formContext.getAttribute(“logicalname”).getValue();

UI object: This is useful when we want to hide any control or disable any control.
formContext.ui.controls
or
formContext.getControl(“logicalname”).getDisabled();
To know more about controls I would recommend to go through Microsoft documents on Controls.

Introduction to an API

What is an API?

API is the acronym for Application Programming Interface, it acts as an intermediary between two application.

Connectivity is a very amazing thing. In today’s world we are very much habituated to instant connectivity across the globe. Ever thought about how does the data travel from one place to another or from a device to an application.
Each time we use any online shopping site or our phone to check weather or Facebook we are using an API.

In a layman’s term an API acts as a messenger, which takes the request from a user and inform the system what a user wants to do, and return the response back to the user.
Example: When you would go to a restaurant you would look into the restaurant menu and place an order to a waiter of the restaurant. The waiter is the person who would take your order from your table to the kitchen where your order would get prepared.

In the above example the waiter acted as a critical link between your order to the kitchen and deliver your food back to your table.
That’s how an API works. It acts as a messenger which takes your request to the system (in our case its kitchen) which tells the system what to do and deliver the response back to you (in our case its the food.)

Now let’s understand the API in a more realistic way. Most of us might have booked a movie ticket using an app or a website. Let’s take an example of BookMyShow app, this app helps us in booking the movie tickets online. Any thought how does the app gets you the movie timing and the tickets fares from different multiplex/malls which are currently running which show. Yes, its the API which play a very important role, the unsung warrior of our connected world.

I would say API acts as an engine who plays a very important role behind the scene, because of API only it is possible to get what we expect and rely upon.

Hope now you are clear with what is an API and its use.

Microsoft Release 2020: Email Enhancement

Microsoft has come up with enhanced email feature in 2020 release wave 1 plan.

Let’s take a closer look into CRM, how the email functionality used to work before enabling the Enhanced Email feature.
User clicks on email activity from timeline, CRM would navigate the user to Email activity screen.

Now, Let’s enable the Enhanced Email feature.

  • Steps to be followed are:
  • Go to Sales and click App Settings
  • Manage Enhanced Mail option would be available
  • Enable Enhanced Email
Figure 3: Enabled Enhanced Email and Hit the Save button

Going back to the Sales. Refresh the browser to get the changes reflected when user click on Email Activity being within any entity.

Figure 4: Now email activity got opened in a separate dialog.

We still get the ability to work on Account form though New Email form is being populated on top of it.

Hope this blog helps in understanding this feature.
Happy D365 CRM

Generate Auto Number for entity without code in D365 CRM

We all know that Microsoft has the auto-number feature, but it has its own prefix for auto-number and its own sequence for generating auto number.
There are many ask from the users that the auto number for an entity should have their org name as a prefix and the random number should be in a particular format.

Today, let’s learn how to implement the auto-number functionality for an entity with the prefix required by business user.

Before we start we should have D365 System Admin rights with us.

Login to D365 CRM online and Navigate to Power Apps portal.
Below is the Power Apps Home page. Click on Data, which gets expanded and show us the entities currently present under the logged in CRM Instance.

Figure 1: Power Apps Home Page

Select the desired entity, I am selecting Account entity.

Figure 2: Select Account entity

The below tabs under the yellow box are the one from where we get to know about the Fields, Relationship, Business Rule, Views etc. present under Account entity.

For achieving the Auto Number functionality, we will create a new field by clicking on “+Add field” button.

Figure 3: Entity details and adding new auto number field

Provide Display name to the field and change the datatype to “Autonumber”.

Then let’s change the value under “Autonumber type” field to Custom. Under Format field we can use custom auto number format.

Seed value is by default 1000, we will be using the same.

Depending on the combination of Format and Seed field. We get the sample output under Preview.
Now, hit the “Done” button.

Figure 4: Create Auto-Number field

Click on Save Entity.

Figure 5: Save the changes done on entity

Now, let’s navigate to our CRM screen and open the Account entity under customization where we can decide where to place the newly created autonumber field (Acc Account Number) on the Account Form and Publish the change.

Figure 6: Field placed on the form, hit the save and publish button.

Going to Account entity and creating a new account. When clicking on Save, we get to see that a random auto number got populated under the Acc Auto Number field.

Figure 7: Auto Number generation

Hope this helps you. Enjoy D365 CRM!

Microsoft Release 2020: Open dialog on button click

Today, we will see how to open an entity main form on top on another entity main form without navigating from one entity to another.

Let’s take an example of Order and Product entity. So, when a user clicks on Order entity main form ribbon button then Product entity main form dialog should get pop up above Order entity main form instead of navigating to Product entity.

Steps to achieve the above functionality:

  • Get the Ribbon Workbench solution installed on the CRM instance.
  • Create a new solution and add Order entity.
  • Create a new web-resource of JavaScript type and add the below JS code in it.
  • Add the web-resource in the solution.
function DialogPopUp()
{
Xrm.Navigation.navigateTo(
{
pageType: "entityrecord",
entityName: "product",
formType: 2
},
{
target: 2,
position: 1,
width: {
value: 70,
unit: "%"
}
});
}

Now, lets open the solution inside ribbon workbench.
Click on Open Solution button on the left top this with pop up a window. Using which we get the ability to select the desired solution which we want to open inside ribbon workbench.

Figure 1: Ribbon Workbench

Drag the Button option from ToolBox menu and place it on the Order form ribbon. Rename the button by inserting a new name in the Label. I have given Product Dialog – the same would get reflected on the Order main form.

Figure 2: Create button on Order entity

Now create a new command by clicking on the “+” icon. This is where we call the JavaScript webresource as shown in the below image and provide the JS function name(DialogPopUp) inside the Function Name field.

Figure 3: Create a new command for calling JS webresource

Enable the Display Rule to True. For this click in the “+” icon next to Display Rule and

Figure 4: Enable Display Rule

Select the button rule as shown in the below image and tag the command inside Command drop-down.

Figure 5: Tag command inside Command drop-down

Now, we need to save our changes therefore hit the Publish button. Post that go back to Order entity and refresh the browser.

Figure 6: Product Dialog button on Order entity.

Hit the Product Dialog button and we should get the Product entity main form on top of SalesOrder entity.

Figure 7: Product Dialog on SalesOrder Entity

Happy CRM!

Microsoft Release 2020: Open Dialog on Lookup field click

Normally, we have observed that whenever a user clicks on any lookup field value. Then the CRM navigates the user to the lookup entity record page.

Today’s we will learn how to stop user from navigating from one page to another page on click of lookup field value. This will help users to have a good experience while using CRM product and increase their productivity on their day to day activity on CRM.
This, will actually reduce the number of click which users makes while navigating from one entity to another entity main form and coming bank again to the main form page.

Let’s take an example of Account entity, when a user go to account entity they may have multiple lookup fields on the Account Main form. Clicking on the lookup field value user gets redirected to the lookup associated entity record. Today’s blog is related to the same scenario where when a user clicks on lookup field value, a dialog should open on the same main form instead navigating the user to another entity main form.

Steps to implement the Lookup dialog functionality and let’s take an example of Account entity.

  • Create a new Javascript web resource.
  • Add the web resource under Account Form libraries.
  • Then call the web resource function (LookupDialog) on the Account entity Form: OnLoad event.
  • Publish the changes.

Below is the code which you can use for achieving lookup dialog functionality. I have made it generic so that the same code can be used for any entity main form OnLoad event.

This feature is achievable with the help of OnLookupTagClick Event.

//Call function onload of form with execution context passed.
function LookupDialog(executionContext)
{
var formContext = executionContext.getFormContext();
//Get all attributes on form on event.
formContext.data.entity.attributes.forEach(function (attribute, index)
{
//For each attribute check whether the attribute type is "lookup" or not.
var attributeType = attribute.getAttributeType();
if(attributeType=="lookup"){
var attrName=attribute.getName();
//If attribute is of lookup type, add OnLookupTagClick event to field
OpenLookupDialog(formContext,attrName);
}
});
}

function OpenLookupDialog(formContext,lookupField)
{
formContext.getControl(lookupField).addOnLookupTagClick(context => {
context.getEventArgs().preventDefault();
const lookupTagValue = context.getEventArgs().getTagValue();
Xrm.Navigation.navigateTo(
{
pageType: "entityrecord",
entityName: lookupTagValue.entityType,
formType: 2,
entityId: lookupTagValue.id
},
{
target: 2,
position: 1,
width: {
value: 70,
unit: "%"
}
});
});
}
Figure 1: Adding Web resource on entity OnLoad event

Post publish –> Go back to the Account entity UCI form and refresh the page.

Figure 2: User click on Primary Contact which is a lookup field.
Figure 3: Contact main form opened on top of Account form.

Now, we have managed to stop the CRM from redirecting us to the lookup record page. Indeed we get the dialog on top of the page we were residing.

We also get the ability to maximize the dialog width to full screen. The option appear in the above picture under the green box. Once the dialog is maximized to to full screen we will still have the “X” icon on the screen. It will allow us to come back directly to the Account main form.

Note: This feature would work only on the UCI form not on Classic form.

Happy CRM! 😊

Microsoft Release 2020: Features (Template Access)

Continuing to the Microsoft Release 2020 features (Previous post: Kanban View feature)
Let’s learn about another new feature which make the users life easy while selecting the template.

  • This feature is available in the Unified Interface only.
  • This capability is available in Dynamics 365 Sales Enterprise and Dynamics 365 Sales Professional.

We have seen in sales organizations that when CRM is implemented, then there are multiple scenario where users need to select templates for notifying there customers.

Then comes a situation where user needs to decide which available template to select and most relevant one. Before wave 1 release 2020, user didn’t had the option to view the template body of the selected template without being redirected to another screen.

Let’s jump and demonstrate the feature.

  • Go to Email template
  • Provide the customer name to whom the email needs to be sent
  • Click on Insert Template button on the ribbon
Figure 1: Insert Template

Now, user will get the access to list of all available email templates from which user needs to scroll and find the most relevant one among them.

This feature helps the user to look on the template content on the same screen and make decisions while selecting the template.

Figure 2: Email Template body
  • Hit the Apply template button.
Figure 3: Template applied.

Now, we see that the selected email template Subject and mail body has been auto-populated under the email activity.

Hope this post helps in understanding the email template feature.

Microsoft Release 2020: Features (Kanban Control)

With the very latest Microsoft D365 Release 2020, Microsoft has come up with many new feature among which one is Kanban.

I will directly start with Kanban feature, how to enable it and it’s use.

To get the Kanban view feature, first we need to ensure that our environment has got the 2020 release wave 1 enabled. To check whether our environment is updated with Microsoft 2020 wave 1 release or not, we need to follow few steps.

Please follow the steps provide by Microsoft to enable the early access of Microsoft 2020 Wave 1 Release.

We have got our environment updated with the wave 1 release.

Let’s jump into enabling the Kanban feature for Opportunity entity. To achieve this feature we need to enable the Kanban control under Opportunity entity.
Step 1: Go to Opportunity entity
Step 2: Click on Controls tab

Figure 1: Click on Controls tab under Opportunity entity.

Step 3: Now click on Add control –> Serach for Kanban –> select Kanban and hit the Add button.

Figure 2: Adding Kanban control to Opportunity entity.

Step 4: Select the Kanban control for Web, Phone and Tablet option. This help us in maintaining a consistent view across all the devices.

Figure 3: Enabling Kanban view.

Step 5: Save and Publish the changes.

Now, Let’s navigate to Opportunity entity.
Here is our new Kanban view, where user has an two Kanban type option:

  • Status
  • Business Process Flow

Currently, I have opened the Open Opportunities view where the Kanban Type is Business Process Flow.
I see that Microsoft has provided their users a flexibility to segregate their opportunities depending on the business process flow stages the opportunities are currently residing.

Figure 4: Kanban View of Open Opportunities Kanban Type: Business Process Flow.

Now, lets open All Opportunities view where the Kanban Type is Status.

Figure 5: Kanban type is set to Opportunity Status
Note: If you are unable to find the Kanban feature after updating wave 1 release 2020. You need to click on the ribbon and select Kanban.
Figure 6: Kanban

Hope this helps!!!

DataMigration: KingswaySoft using Merge Join

Merge Join component is used when we want to merge the data coming from different source or data flow. Merge Join provide us the data as a combine source or single source after merging the data from different sources.

Point to be noted: For using Merge Join it’s mandatory to use Sort component.

Merge Join: Combine two sorted data flows into one using the FULL, LEFT, or INNER join. It’s recommended that during transformation of data flows sorting to be used at their sources.

Figure 1: We can find this component from SSIS toolbox
Figure 2: Using Sort component for Merge Join

Merge Join Editor: Here, we get the ability to specify the type of join we want for merging the data coming from Sort components. Under this editor we can either use Inner Join, Let Outer Join or Full Outer Join.
Under merge join component we get all the fields/attributes which are passed under Sort component from their respective data source.

Now, we need to map the fields coming from different sources and pass through Sort component. If the fields is not marked for Pass Through under Sort then the field won’t populate under Merge Join Editor and mapping would not be possible for that field.

Figure 3: Merge Join Editor

Under Sort Editor we need to check the field under Pass Through column. If the field is unchecked then the field would not populated under Merge Join component editor.

Figure 4: Sort Editor

Example: If the checkbox next to UniqueID is not checked under Pass Through, then it would not populate under Merge Join Component Input Column.

Also, we need to select one field on top of which sorting order would be done.
In my case I selected a field which contains unique data in the entire data flow fields.

We can also decide the Sorting Order for the fields as it should be in ascending or descending order.

Hope this explanation help you!

DataMigration: KingswaySoft using Pivot

Today, we will learn how to transform data into row from columns pattern.

For retrieving data using FetchXML, we may get data in vertical format like we may get multiple row fields. Depending on the entity relationship and data categorization.

Whenever we face such kind of scenario we need to opt for pivot component.

LRRequestIDLR_Split_AMTLR_name
Blog\0011\201986805.56ATM
Blog\0011\20199333.33DA
Blog\0012\201979320ES
Blog\0013\201930288.46IMS
Blog\0013\2019165270ATM
Blog\0013\201950000DA
Figure 1: Data Format when retrieved from FetchXML

I would say that Pivot component basically transform the data to view from different perspective.

Figure 2: Pivot Component
Figure 3: Pivot Editor

For Pivot we will be using same 3 attribute displayed in Figure 1.

LR_name will be our Pivot Key, LR_Split_AMT will be our Pivot Value and LRRequestID will be our Set Key.
Using this LR_name as a pivot key would split its value into different columns in the destination db and LRRequestID unique for each row.

LRRequestIDATMDAESIMS
Blog\0011\201986805.569333.33  
Blog\0012\2019  79320 
Blog\0013\201916527050000 30288.46
Figure 4: Output result

To achieve the result as shown in figure 4, we also need to perform some additional step.
Right click in the Pivot component and click on Show Advanced Editor option.
Inside the Input and Output Properties we will see the three columns(Pivot Key, Pivot Value and Set Key) attributes in the Input Columns tab.
Now, as per the desired output (Figure 4), we need the LR_Split_AMT to be captured in a single row inside the destination db against LRRequestID. Therefore we will need to take the LineageID of the LR_Split_AMT attribute as show in the below image under blue border.

Figure 5: Pivot Advance Editor

Post that we need to click on Output columns and hit Add Column button. Where we need to create 4 new columns against each LR_name.

  • **Points to Remember for all four new collumns:
  • Name the column as you desire
  • Under Custom Properties
    PivotKeyValue:
    Name the value in the exactly same manner how its appears when fetched from CRM.
    SourceColumn: Provide the LineageID of LR_Split_AMT as explained above.
Figure 6: Pivot Advance Editor

That’s all about Pivot component.

Lastly, we will need to map the newly created output columns to the destination db columns in their data flow for proper data presentation.

Thank You.. Hope this post helps anyone.

Design a site like this with WordPress.com
Get started