Category Archives: Microsoft Dynamics CRM

How to Bulk Update CRM Records Using the Bulk Workflow Execution Tool

Feature Image 3 300x225 How to Bulk Update CRM Records Using the Bulk Workflow Execution Tool

That’s right – no more being limited to mass updating only 250 records at once in Dynamics 365! The Bulk Workflow Execution is a great tool which allows users to run an On-Demand Workflow against a set of records pulled from a System or Personal View, all in bulk! You can find the “Bulk Workflow Execution” tool in the Plug-in Store using the XRMToolBox application.

Let’s look at a quick example of how the tool works. Say that you need to change the Owner of 10,000+ Case records. Follow the steps below:

1. Create an On-demand Workflow.

021918 1640 HowtoBulkUp1 How to Bulk Update CRM Records Using the Bulk Workflow Execution Tool

2. Create a Personal View or use an existing System View to pull your data set.

021918 1640 HowtoBulkUp2 How to Bulk Update CRM Records Using the Bulk Workflow Execution Tool

3. Open XRMToolBox.

4. Scroll and click the Bulk Workflow Execution.

5. Click Yes to connect to your Dynamics 365 organization.

021918 1640 HowtoBulkUp3 How to Bulk Update CRM Records Using the Bulk Workflow Execution Tool

6. Type your Organization URL.

021918 1640 HowtoBulkUp4 How to Bulk Update CRM Records Using the Bulk Workflow Execution Tool

7. Type your Username/Password and click Connect.

021918 1640 HowtoBulkUp5 How to Bulk Update CRM Records Using the Bulk Workflow Execution Tool

8. Type a Name for your organization after it successfully connects. NOTE: once the organization connection is established, XRMToolBox will open a new tab with the tool name and organization name you provided.

9. Select the On-Demand Workflow you created from the dropdown and wait for the tool to retrieve the applicable Views.

021918 1640 HowtoBulkUp6 How to Bulk Update CRM Records Using the Bulk Workflow Execution Tool

10. From the View list, select the System View or Personal View you are running the On-Demand Workflow against. Note: you should see the FetchXML Query populated in the area to the right after you select the View from the list.

11. Click Validate Query to verify the amount of records being pulled in the data set.

021918 1640 HowtoBulkUp7 How to Bulk Update CRM Records Using the Bulk Workflow Execution Tool

12. Determine your Batch Size and Interval Delay.
Note: if unsure, keep the default Batch Size at “200” and Interval Delay at “0” seconds

13. When ready, click Start Workflows.

021918 1640 HowtoBulkUp8 How to Bulk Update CRM Records Using the Bulk Workflow Execution Tool

14. The tool will run and will inform you of progress.

021918 1640 HowtoBulkUp9 How to Bulk Update CRM Records Using the Bulk Workflow Execution Tool

15. When finished, the tool will display a small window indicating the time it completed, how many records the workflow ran against, and number of errors as a result of the execution.

021918 1640 HowtoBulkUp10 How to Bulk Update CRM Records Using the Bulk Workflow Execution Tool

A good rule of thumb is allowing about 2 seconds per record for the tool to update a record. That would be 30 records per minute and 1,800 records per hour. Remember that this tool is completely automated! So, while the job runs you can leave your computer unattended or have it running in the background if multitasking.

That’s it! For more Tips & Tricks and other educational materials on Dynamics 365, check out our blog.

Happy Dynamics 365’ing!

Let’s block ads! (Why?)

PowerObjects- Bringing Focus to Dynamics CRM

Dynamics 365 Record Hierarchy

Dynamics 365 (CRM) has a neat feature, Record Hierarchy, that can be easily overlooked, but can provide great visual insight into your customers. In this post, we will explore the components that make up this feature.

What Is Record Hierarchy?

The Record Hierarchy in Dynamics 365 is actually a simple concept. It boils down to parent/child relationships. For example, “Fictional Company” is the headquarters which has multiple branch offices, or companies that it owns, in different locations.

Account Records Hierarchy

Parent Accounts within Dynamics 365 (CRM) have been around for a while. However, with the Hierarchy options available, you can visualize the relationships between accounts. So, let’s explore this set-up.
Below, you will see a list of Accounts with the Hierarchy IconHierarchy icon Dynamics 365 Record Hierarchy at the left of the Account Name.

Accounts View with Hierarchy Icons 625x462 Dynamics 365 Record Hierarchy

Due to the Parent Account field being populated on the Account record the hierarchy icon is displayed. For example, on the “Alpine Ski House” account, the Parent Account is “Fabrikam, Inc.”.

Account Record with Parent Account 625x451 Dynamics 365 Record Hierarchy

Now, by simply clicking on the Hierarchy Icon, you can see the hierarchy of the accounts and how they are connected.
Hierarchy View of Accounts 625x347 Dynamics 365 Record Hierarchy

As you can see, “Fabrikam, Inc” is sitting at the top level with the companies that it owns sitting underneath. Next, by clicking on one of the sub-companies, the hierarchy view will expand further.
Hierarchy View of Sub Accounts 625x343 Dynamics 365 Record Hierarchy

TIP: To open a record from the Hierarchy View, simply click the icon in the top-right corner of the record tile.
Hierarchy Tile Open Record option Dynamics 365 Record Hierarchy

User Records Hierarchy

In addition to Account Records, User Records can be visualized with hierarchy. So, let’s review how this works.

Below is a list of User Records with the Hierarchy Icon next to the names. Since managers have been set for the users, the hierarchy icon will be displayed.
Users View with Hierarchy Icons 625x458 Dynamics 365 Record Hierarchy

How this icon is displayed is based on the Manager being added to the User Record.

User Record with Manager 625x196 Dynamics 365 Record Hierarchy

You can add a manager to a user by clicking the “Change Manager” button at the top of the User Record.

Change Manager button Dynamics 365 Record Hierarchy

Therefore, when the icon next to “Dan Jump” is clicked, you can visually see the hierarchy.
Hierarchy View of Users 625x346 Dynamics 365 Record Hierarchy

Next, you can click on a tile below “Dan Jump” to see who reports to this person.
Hierarchy View of Managers 625x282 Dynamics 365 Record Hierarchy

Hierarchy Settings

The Hierarchy visualizations and connections are achieved through the Hierarchy Settings on the entities. You can check the current Hierarchy Settings of an existing entity, or add a new Hierarchy, from the solutions area.

First, you will need to navigate to Settings>Customizations>Customize the System, or Settings>Solutions and select the appropriate solution file.

Next, expand the appropriate entity and select “Hierarchy Settings”.
Hierarchy Settings in solution 625x274 Dynamics 365 Record Hierarchy

Next, double-click on the “Account Hierarchy” listed and you will see how this is set up.

Account Hierarchy Settings 625x249 Dynamics 365 Record Hierarchy

As you can see in the “Hierarchical Relationship” field, this setting is based on the “Parent Account” relationship. So, let’s look at where this is found.

First, you will need to navigate to the One-to-Many (1:N) Relationships under the Account entity.

Account one to many Relationships 625x234 Dynamics 365 Record Hierarchy

Next, double-click on the relationship listing, and you will see how this is set up.

Account one to many Relationships Parental Dynamics 365 Record Hierarchy

Hierarchy in Advanced Finds

The last area we will cover is Advanced Finds. Once hierarchies have been set up with all the appropriate entities, you can utilize Advanced Finds to find data. In the below examples, we will look at Accounts and Opportunities.

First, navigate the “Active Accounts” View in Dynamics 365. Then, click on the “Advanced Find” icon to open the “Advanced Find” window. Next, select “Accounts”, “Under”, and then in the last field select the Parent Account which is “Fabrikam, Inc.”.
Advanced Find Accounts Under Parent Account 625x256 Dynamics 365 Record Hierarchy

Now, the results returned will be Active Accounts that are under the Parent Account of “Fabrikam, Inc.”.

Advanced Find Accounts Under Parent Account Results 625x151 Dynamics 365 Record Hierarchy

By the way, these results can be checked by viewing the Hierarchy Visualizations area.

Hierarchy View of Sub Accounts 625x343 Dynamics 365 Record Hierarchy

The next area we will look at is Opportunities under a specific Account. So, you will need to open the Advanced Find window again. But, if you already have it open, just change the “Look for” field to “Opportunities”.

In the query area, select “Status equals Active”, and “Account under Fabrikam, Inc.”. Due to these query settings, the results will show all Active Opportunities under the Parent Account of “Fabrikam, Inc.”.

Advanced Find Opportunities Under Account Dynamics 365 Record Hierarchy

Next, click on the “Results” button to view the results. Now, you should see all the opportunities under the child accounts under the parent “Fabrikam, Inc” account.
Advanced Find Opportunities Under Account Results 625x431 Dynamics 365 Record Hierarchy

In Conclusion

The Hierarchy options can help you visualize or find important customer data within Dynamics 365. Because many people consume data in different ways, having a visual method to see the data is a great “tool” to have at your fingertips. So, the next step is for you to try these things in your system!

Let’s block ads! (Why?)

CRM Software Blog | Dynamics 365

How to Organize Dynamics CRM Documents in SharePoint

CRM Blog How to Organize Dynamics CRM Documents in SharePoint

How to Organize Dynamics CRM Documents in SharePoint

Not many companies are aware of the capability of Dynamics CRM and SharePoint integration, and the benefits for their business.  Microsoft Dynamics CRM and SharePoint Integration helps users to view and share stored documents easily, and increase productivity and strengthen the collaboration between the different business units and teams in the organization.

Although SharePoint is included in Office 365 plan, not many organizations are utilizing this service and integrate it with Dynamics 365. In an article published recently (Read Here), we point out the limitations inherent from CRM out-of-box integration with SharePoint:

Documents are stored in complex folders and sub folders structure.

  1. CRM documents are either stored in standalone unrelated SharePoint folders

Or

  1. They are stored in folders related to Account or Contact only, no other entity can be selected to link between related documents

Folder names are the content of the Name field of records:

  1. The content is not unique and can create confusion and duplications
  2. The content is meaningless to the SharePoint users searching for documents

No metadata is saved in SharePoint columns. Relevant metadata is crucial for classifying documents in SharePoint:

  1. To group records in library view (two grouping levels)
  2. You cannot assign Content Type to the uploaded document
  3. Relevant metadata ensures the return of relevant search results

This blog post suggests an organized way to store documents from CRM in SharePoint using these folders and metadata:

  1. Which folder structure suits better for storing documents in SharePoint.
  2. The benefits using metadata with
    1. Views
    2. Metadata Navigation
    3. Content Type
    4. Search

 

Which folder structure suits better for storing documents in SharePoint.
Consider an organization that provides services, quoted by sales people. When quote is won, the client signs Service Contract. During the contract period, the organization raises invoices and client payments are recorded in Payment Receipts entity. The above process is a collaboration between two teams, one is using CRM the other is using SharePoint.

CRM Entity Common type of documents Entity Type
Quote PDF of the quote emailed to client Out of box Entity
Invoice Invoice generated by Accounts or CRM Out of box Entity
Service Contract Signed service contract (PDF) Customised Entity
Payment Receipts Proof of payment (PDF, scanned image) Customised Entity

All the above four document types are related to the company that purchases the service. For the purpose of this blog, we will be using Adventure Works as the Account name.

Entity folder structure – all documents from an entity are stored in a folder that bears the entity name. Documents uploaded from the Quote entity will be stored in SharePoint Quote folder. The assumption is that documents are mostly related to their entity and less to other entities or related entities.

Parent entity folder structure – all documents from all entities relating to a parent entity are stored in a folder that bears the parent entity name. Documents uploaded from the Quote, Invoice, Service Contract, and Payment Receipts entities will all be stored in one folder in SharePoint, Adventure Works folder. The idea is storing together all documents from different entities, which are all related to one “central” parent entity.

Combined: Entity folder with parent entity folder structure – when selecting these two folder structures, the Quote, Invoice, Service Contract and Payment Receipt documents will be saved in Adventure Works folder, together with documents from the Adventure Works entity. Combining all documents related to the parent and the child entities in one folder that bears the parent entity name, is useful when documents from the parent and the child are closely related to each other.

Parent / Child folder structure – documents uploaded from an entity are stored in a folder that bears the entity name, which is a SharePoint sub folder to a folder that bears the parent entity name. In the above example, the parent folder is Adventure Works and it has four subfolders for documents uploaded from Quote, Invoice, Service Contract and Payment Receipt entities. The first document uploaded, also creates the parent / child folder and sub folder structure in SharePoint.

Dynamics SPO users that are already using Dynamics CRM OOB integration with SharePoint, can also select the option to maintain the OOB folder structure in SharePoint, for those entities already using this methodology.

Using metadata fields in SharePoint columns.

When documents are uploaded from CRM to SharePoint, the content of selected attributes / fields from the CRM record are saved with the document in columns. Here are the benefits of using metadata:

  1. Views- use views to filter documents in a library, and list them as it best fits to particular purpose. You can set how documents are sorted in a view or filter them by date range. As an example, if Account Name and Invoice Date are saved as metadata, you can view all invoices for an account, which were created or are over-due for payment, within a date range.
  1. Metadata Navigation- makes it easier for users to find content. Metadata navigation enables users to filter and find documents in libraries by using a navigation tree. You can also apply Key Filters, which work in combination with the navigation tree to refine the list of documents to display.
  2. Content Type- is a reusable collection of metadata columns and other settings for a category of items or documents in SharePoint. In our above example, although Invoices, Quote Receipts and Service Agreement each has different content type, they can share some metadata, such as the client name (Account Name), and Document ID. When documents are uploaded to SP with Dynamics SPO, each document can be associated with its content type.
  3. Search – is a powerful tool to locate documents in SharePoint. Adding metadata column to the crawler contributes to finding relevant documents in search results.

If you are interested in better integration between Dynamics CRM and SharePoint download FREE trial of Dynamics SharePoint organizer (SPO):

http://www.dynamicsobjects.com/Solutions-for-Digital-Transformation/Upload-Documents-to-SP

.

Let’s block ads! (Why?)

CRM Software Blog | Dynamics 365

Driving Success For Your Dynamics 365 Journey [VIDEO]

Driving Success Still 800x600 300x225 Driving Success For Your Dynamics 365 Journey [VIDEO]

No matter where you are on your Dynamics 365 journey, we can help! PowerObjects’ unparalleled offerings of service, support, education, and add-ons for Microsoft Dynamics 365 have made us a go-to partner for an end-to-end solution. Whether you are new to Dynamics 365 or have a mature solution, whether you are on-premises or online, whether you are a small business or an enterprise organization, the team at PowerObjects can help you get the most out of Dynamics 365! Watch this video to get an inside look and hear from some of our customers about why PowerObjects is the right partner for your journey.

Let’s block ads! (Why?)

PowerObjects- Bringing Focus to Dynamics CRM

The New Auto Number Feature in Dynamics 365

New Auto Number Features 300x225 The New Auto Number Feature in Dynamics 365

Auto numbers or unique alphanumeric strings are usually needed by CRM users to uniquely identify records in UI. We have developed plugins in the past, which would generate unique identifiers for us by using counters or random strings.

Microsoft has released an “Auto number” attribute in the 9.0 version of Dynamics 365. Adding the attribute from UI is not allowed yet, but it will be soon. Until then, we can add the attribute via API.

Let’s add one.

1. Create a console application in Visual Studio.

021518 1842 TheNewAutoN1 The New Auto Number Feature in Dynamics 365

2. Add the Dynamics 365 V9.0 dlls as references. Currently, the preview version of the dlls is available in NuGet.

https://www.nuget.org/packages/Microsoft.CrmSdk.CoreAssemblies/9.0.0.4-Preview

3. Create a connection to your organization and call the CreateAutoNumberAttribute function from the Main() function.

using System;

using System.Collections.Generic;

using System.Linq;

using System.Text;

using System.Threading.Tasks;

using System.Configuration;

using Microsoft.Xrm.Sdk;

using Microsoft.Xrm.Sdk.Query;

using Microsoft.Xrm.Sdk.Client;

using Microsoft.Xrm.Sdk.Messages;

using Microsoft.Xrm.Sdk.Metadata;

using System.ServiceModel.Description;

static
void Main(string[] args)

{


string orgServiceUrl = ConfigurationManager.AppSettings[“orgServiceUrl”];


string userName = ConfigurationManager.AppSettings[“username”];


string password = ConfigurationManager.AppSettings[“password”];


Uri oUri = new
Uri(orgServiceUrl);


//** Your client credentials


ClientCredentials clientCredentials = new
ClientCredentials();

clientCredentials.UserName.UserName = userName;

clientCredentials.UserName.Password = password;


//Create your Organization Service Proxy


OrganizationServiceProxy _serviceProxy = new
OrganizationServiceProxy(

oUri,


null,

clientCredentials,


null);

CreateAutoNumberAttribute(“account”, “new_accountnumber”, _serviceProxy);

}

4. Following function creates an auto number attribute of “string” type in “Account” entity.

“AutoNumberFormat” is the new property that has been added to the AttributeMetadata class to help us add the auto number attribute.

public
static
void CreateAutoNumberAttribute(string entityName, string attributename, OrganizationServiceProxy _orgServiceProxy)

{


CreateAttributeRequest newAttributeReq = new
CreateAttributeRequest

{

EntityName = entityName.ToLower(),

Attribute = new
StringAttributeMetadata

{

AutoNumberFormat = “ACC-{RANDSTRING:6}”,

LogicalName = attributename.ToLower(),

SchemaName = attributename.ToLower(),

MaxLength = 150,

RequiredLevel = new
AttributeRequiredLevelManagedProperty(AttributeRequiredLevel.None),

FormatName = StringFormatName.Text,

DisplayName = new Microsoft.Xrm.Sdk.Label(“Account Number”, 1033),

Description = new Microsoft.Xrm.Sdk.Label(“Unique alphanumberic number for each account”, 1033)

}

};

_orgServiceProxy.Execute(newAttributeReq);

}

5. Time to check out the new attribute!

021518 1842 TheNewAutoN2 The New Auto Number Feature in Dynamics 365

6. Let’s create few accounts and check the auto numbers!

021518 1842 TheNewAutoN3 The New Auto Number Feature in Dynamics 365

7. 9.0 version of Dynamics 365 supports the following tokens for Auto numbers:

Static String
DATE:[format]
SEQNUM:size
RANDSTRING:6

There you have it! We’re happy to have this feature added to Dynamics 365. Be sure to check out our blog for more updates, news, and tips for Dynamics 365!

Happy Dynamics 365’ing!

Let’s block ads! (Why?)

PowerObjects- Bringing Focus to Dynamics CRM

The Colchester Borough Council: Dynamics 365 Case Study

Colchester Case Study 300x225 The Colchester Borough Council: Dynamics 365 Case Study

The Colchester Borough Council (The Council) is a local government authority serving approximately 190,000 residents within the County of Essex in the United Kingdom. Resident services include refuse and recycling collection; housing advice; food and safety inspection; planning services; and licensing and permitting.

Microsoft Dynamics 365 provides The Council with a front to back office solution, visibility across the organization and mobile capabilities to better assist residents. The Council leveraged PowerObjects’ Education Team to create custom training to advance internal skill sets to extend current customizations and successfully deploy future developments.

“The philosophy of teaching a man how to fish seems to be embedded in PowerObjects’ consulting philosophy,” says Piercy. “They ask what you want to accomplish and then teach you the way to do it.”

Read The Colchester Borough Council’s Dynamics 365 Customer Success Story now!

Happy Dynamics 365’ing!

Let’s block ads! (Why?)

PowerObjects- Bringing Focus to Dynamics CRM

How to Change User Session Timeout Settings in Dynamics 365 Online

In Microsoft Dynamics 365 online, timeout for a user’s session is set to 24 hours by default. This means a user is not required to re-enter their login details for up to 24 hours. However, now we can update these settings based on our requirements. In this blog, I will go through the steps to make such changes.

In Dynamics 365 online instance, go to Settings Administration System Settings. Then click on General tab.

Under the section Set session timeout, we need to set “Session timeout settings” to “Set custom”. This will allow us to change the maximum session length and how long before the warning is shown.

I decided to set maximum session length to 300 and I wanted the users to be shown the timeout warning 25 minutes before the session expired. The following screenshot shows what I changed the values to.

image thumb How to Change User Session Timeout Settings in Dynamics 365 Online

The value for maximum session length need to be between 60 and 1400, and the value for timeout warning has to be between 20 and 1439. If invalid values are entered an error message is shown like the one in following screenshot.

image thumb 1 How to Change User Session Timeout Settings in Dynamics 365 Online

Be sure to click on OK once the changes have been made.

There are a few things that we must keep in mind. The user making these changes needs to be a System Administrator and changes are applied to all the users.

Let’s block ads! (Why?)

Magnetism Solutions Dynamics CRM Blog

Fixing Incorrect Views Width After CRM 2011 to Dynamics 365 Upgrade

Recently, we upgraded a client’s CRM 2011 to Dynamics 365. For some entities, the associated view of related entities of a record didn’t have the correct width when accessed from the navigation area, resulting in some whitespace to the right of the screen as shown in the yellow highlighted area below.
  image thumb Fixing Incorrect Views Width After CRM 2011 to Dynamics 365 Upgrade
After some trial and error, I found a solution to this problem. In this blog, I will walk through the steps to overcome this issue.

Solution:
1) Open the form editor. For example, I opened the form editor for Contact form (assuming the record was of type Contact and Activities associated view had incorrect width).
2) Remove the entities from the Navigation that had incorrect views width when being viewed from the form’s navigation area. To do this first click on “Navigation”, and then remove the entity relationship by double clicking on it. For instance, to remove Activities entity from navigation area, I would click on “Activities” on left of the page, and then click on “Remove” button.

image thumb 1 Fixing Incorrect Views Width After CRM 2011 to Dynamics 365 Upgrade

3) Then save and close the form, and be sure to publish all the changes.
4) Then open the same form again, and add the removed entity back into navigation area. To do this, locate the entity on right of the screen, double click on it. Then relocate the entity on navigation are by dragging it if required.

image thumb 2 Fixing Incorrect Views Width After CRM 2011 to Dynamics 365 Upgrade

5) Save and close the form changes, and be sure to publish all the changes.

When we go back to the same associated view of the related entity, we can now see that the view takes up the full screen width.

image thumb 3 Fixing Incorrect Views Width After CRM 2011 to Dynamics 365 Upgrade

Note: This approach also works if you are using Editable Grids instead of normal views.

Let’s block ads! (Why?)

Magnetism Solutions Dynamics CRM Blog

Dynamics 365 Online Authenticate with User Credentials

Integrating with Dynamics 365 Online is straightforward since it exposes Web API endpoints. But the hardest bit is authenticating since Dynamics 365 Online uses OAuth2.0 as an authentication method, a valid access bearer token issued by Microsoft Azure Active Directory is needed and used in every HTTP requests to the Web API.

image thumb Dynamics 365 Online Authenticate with User CredentialsThere are a couple of ways to authenticate and obtain a bearer token which will be covered in future blogs but in this blog, I will cover using user credentials (Active CRM user’s username and password). Also covered is how to obtain a bearer token from a refresh token when token is expired. Here are the steps you would need to follow to authenticate using User Credentials.

1.    Get Bearer Access Token by sending HTTP POST request to Token endpoint

The Token URL endpoint for any Dynamics 365 Online instances would be https://login.microsoftonline.com/common/oauth2/token

The body content of the HTTP Request will contain the following and will be URL encoded.

Key Value Description
client_id 2ad88395-b77d-4561-9441-d0e40824f9bc Default Client Id which is setup against Dynamics 365 Online instances.
resource https://authenticatedemo.crm6.dynamics.com/ Dynamics 365 Online Instance URL
username john@authenticatedemo.onmicrosoft.com Active CRM Users username
password Passw0123 Active CRM Users password
grant_type password

Password set as a grant type

HTTP POST Request:

HTTP Response:

HTTP/1.1 200 OK

Content-Type: application/json; charset=utf-8

{
     “token_type”: “Bearer”,
     “scope”: “user_impersonation”,
     “expires_in”: “3599”,
     “ext_expires_in”: “0”,
     “expires_on”: “1513203043”,
     “not_before”: “1513199143”,
     “resource”: “https://authenticatedemo.crm6.dynamics.com/”,
     “access_token”: “eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiIsIng1dCI6In……………… “,
     “refresh_token”: “AQABAAAAAABHh4kmS_aKT5XrjzxRAtHzAKfFmI……………….. “
}

2.    Set the Authorization Header of the HTTP GET request

From HTTP Response in step 1, extract the string value of the access token key which will be the bearer token.

{
     “token_type”: “Bearer”,
……………………………………………
   “access_token”: “eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiIsIng1dCI6In……………… “,
     “refresh_token”: “AQABAAAAAABHh4kmS_aKT5XrjzxRAtHzAKfFmI………………. “
}

Set the Authorization header value of the HTTP OData request to be Bearer

HTTP GET Request:

HTTP Response:

HTTP/1.1 200 OK
Content-Type: application/json; odata.metadata=minimal
OData-Version: 4.0

{

“@odata.context”:”http://authenticatedemo.api.crm6.dynamics.com/api/data/v9.0/$ metadata#accounts(name)”,

“value”:[

{

“@odata.etag”:”W/\”1257828567\””,”name”:”Test A”,”accountid”:”e0b6ae92-4230-e711-80bf-00155d048d78″

}

]

}

3.    Refresh Expired Bearer Access Token

Use the refresh token to obtain a new access token once previous token has expired.
The body content of the HTTP Request will contain the following and will be URL encoded

Key Value Description
client_id 2ad88395-b77d-4561-9441-d0e40824f9bc Default Client Id which is setup against on Dynamics 365 Online instances
resource  https://authenticatedemo.crm6.dynamics.com/ Dynamics 365 Online Instance URL
refresh_token AQABAAAAAABHh4kmS_aKT5XrjzxRAtHz…. The string value of the refresh token key obtained in step 1.
grant_type refresh_token refresh_token set as a grant type

HTTP POST Request:

POST https://login.microsoftonline.com/common/oauth2/token
Accept: application/json
Content-Type: application/x-www-form-urlencoded

client_id=2ad88395-b77d-4561-9441-d0e40824f9bc&
resource=https%3A%2F%2Fauthenticatedemo.crm6.dynamics.com%2F&
refresh_token=AQABAAAAAABHh4kmS_aKT5XrjzxRAtHzAKfFmI…………………………………&
&grant_type=refresh_token

HTTP Response:

HTTP/1.1 200 OK
Content-Type: application/json; charset=utf-8

{
     “token_type”: “Bearer”,
     “scope”: “user_impersonation”,
     “expires_in”: “3599”,
     “ext_expires_in”: “0”,
     “expires_on”: “1513203043”,
     “not_before”: “1513199143”,
     “resource”: “https://authenticatedemo.crm6.dynamics.com/”,
     “access_token”: “eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiIsIng1dCI6In……………………………”,
     “refresh_token”: “AQABAAAAAABHh4kmS_aKT5XrjzxRAtHzAKfFmI…………………………… “
}

Store the refresh token safely in a database or any other storage system, then you can reuse this refresh token every time to obtain a new access token. So, if the Dynamics 365 user changes their password this method of using the refresh token to authenticate will still work.

Let’s block ads! (Why?)

Magnetism Solutions Dynamics CRM Blog

How to Calculate Number of Days Between Two Date and Time Fields

Tips 300x225 How to Calculate Number of Days Between Two Date and Time Fields

In today’s blog, we are going to demonstrate how to calculate the difference in the number of days between two date and time fields. This functionality also works for the Date & Time and Date Only field as well as the Date Only and Date Only fields. Which means that you can use any possible combination of custom or out-of-the-box Date fields.

In the scenario below, we will estimate the number of days it took the Sales Rep to qualify a Lead to an Account.

Lead Creation Date

First, we will create a Lead Created On field that will hold the information we already possess on the Lead record. In the scenario below, we are using the Date & Time field, as the Created On field on the Lead record is the same format.

021218 1639 HowtoCalcul1 How to Calculate Number of Days Between Two Date and Time Fields

 Calculated Field

The next thing we have to do is to create a Calculated field type Decimal Number. The reason we have selected Decimal Number is because we are using two Date & Time fields as Dynamics 365 includes the Created on Time as part of the calculation. However, we are interested only on the number of days so we will set the Precision value to zero (0). You also can use a Whole Number field type based on your project requirements.

021218 1639 HowtoCalcul2 How to Calculate Number of Days Between Two Date and Time Fields

Calculation Logic

Once you have saved the field, click on edit and set up the logic. In this scenario, we will use the DiffinDays function and specify the start and end date and time. Although, when using the DiffinDays function within the brackets it specifies Date & Time field, the functionality equally works if you select Date Only field type.

021218 1639 HowtoCalcul3 How to Calculate Number of Days Between Two Date and Time Fields

In Action

After saving and publishing the changes, we can go back to the form and test the new function.

021218 1639 HowtoCalcul4 How to Calculate Number of Days Between Two Date and Time Fields

There you have it! For more tips and tricks for using Microsoft Dynamics 365, keep checking our blog!

Happy Dynamics 365’ing!

Let’s block ads! (Why?)

PowerObjects- Bringing Focus to Dynamics CRM