Microsoft Dynamics CRM

{Code Tip} Get record ID using FetchXml for any entity record based on MAX or MIN field value

I had written some posts a while back on Aggregate FetchXml queries here:

https://dynamicsofdynamicscrm.com/2014/07/23/aggregate-fetchxml-queries-for-dynamics-crm-20112013/

https://dynamicsofdynamicscrm.com/2015/10/01/code-tipaggregate-fetchxml-queries-code-for-dynamics-crm/

Recently in a project somebody referred to my query to first get the highest opportunity estimated revenue and then used a second query for getting the record id by passing a condition for highest revenue returned via the first aggregate query.

There is a lot simpler approach and single query which can be used for scenarios like:

“Get the recordid for the record where field is maximum across all records”

or

“Get the recordid for the record where field is minimum across all records”

Here are some examples below with Opportunity and estimated revenue on CRM online trial data:

Opportunity with highest estimated revenue

<fetch top=1>

  <entity name=opportunity>

    <attribute name=name/>

    <attribute name=estimatedvalue/>

    <filter type=and>

      <condition attribute=estimatedvalueoperator=not-null/>

    </filter>

    <order attribute=estimatedvaluedescending=true/>

  </entity>

</fetch>

Output is as below:

clip_image001[4]

Opportunity with lowest estimated revenue

<fetch top=1>

  <entity name=opportunity>

    <attribute name=name/>

    <attribute name=estimatedvalue/>

    <filter type=and>

      <condition attribute=estimatedvalueoperator=not-null/>

    </filter>

    <order attribute=estimatedvalue/>

  </entity>

</fetch>

Output is as below:

clip_image002[4]

However, in practical scenarios it is always good to do a comparison with second highest or second lowest Opportunity estimated revenue(even more or can filter by some id fields/etc.).

Top 2 opportunities with highest estimated revenue

Output i

<fetch top=2>

  <entity name=opportunity>

    <attribute name=name/>

    <attribute name=estimatedvalue/>

    <filter type=and>

      <condition attribute=estimatedvalueoperator=not-null/>

    </filter>

    <order attribute=estimatedvaluedescending=true/>

  </entity>

</fetch>

Output is as below:

clip_image003[4]

Bottom 2 Opportunity with lowest estimated revenue

<fetch top=2>

  <entity name=opportunity>

    <attribute name=name/>

    <attribute name=estimatedvalue/>

    <filter type=and>

      <condition attribute=estimatedvalueoperator=not-null/>

    </filter>

    <order attribute=estimatedvalue/>

  </entity>

</fetch>

Output is as below:

clip_image004[4]

Hope it helps and Happy CRMing!

ABOUT THE AUTHOR:

clip_image001

Twitter: https://twitter.com/msdynamicsblog
LinkedIn: https://www.linkedin.com/in/deepesh-somani-00296932

Google Play Store:

https://play.google.com/store/apps/details?id=com.dynamicsofdynamicscrm.msdynamicsblog&hl=en

Microsoft Dynamics CRM

{Dynamics 365 Enhancements} Good reads from the CRM community

This blog is part of the series which I will use to cover all interesting enhancements coming in Dynamics 365.

People often ask me how can they start blogging and then keep maintaining to write. The trick is very simple!

clip_image001

In this post, I am going to cover the knowledge and good reads about Dynamics 365 from CRM community.

A great article from Nishant on Dynamics 365 Apps: https://nishantrana.wordpress.com/2016/11/03/create-apps-in-dynamics-365-using-new-app-designer-and-site-map-designer-in-dynamics-365/

Learn about the new Business rules visual designer here:

https://nishantrana.wordpress.com/2016/11/02/new-visual-designer-for-business-rules-in-dynamics-365/

You must have read about Editable grids, if not its summed up by really well here by Nishant:

https://nishantrana.wordpress.com/2016/11/01/quick-walkthrough-editable-grid-in-dynamics-365/

Fellow MVP Debajit has more interesting details to read here on Editable grids:

https://debajmecrm.com/2016/11/05/dynamics-365-quick-tips-rearrange-columns-on-the-fly-and-maintain-view-groupings-and-switch-display-mode-in-dynamics-365-editable-grids/

Following up, a set of new out of box actions that are now readily available for Dynamics CRM:

https://debajmecrm.com/2016/11/03/dynamics-365-new-features-explore-the-new-oob-actions-available-with-dynamics-365/

Very interesting read about Azure Logic apps by Simaranjit here:

https://crmazurecomponents.wordpress.com/2016/11/13/azure-logic-apps-twitter-to-facebook/

A look at preview feature for Organization insights here:

https://crmazurecomponents.wordpress.com/2016/11/03/dynamics-365-preview-feature-organization-insights-dashboard/

This blog from MVP Neil on Business process flows enhancements is not to be missed:

https://neilparkhurst.com/2016/11/06/dynamics-365-business-process-flows/

Do not forget, Public beta for Dynamics 365 SDK is released : https://marketplace.visualstudio.com/items?itemName=DynamicsCRMPG.MicrosoftDynamicsCRMDeveloperToolkit

Hope you liked the power of CRM community.

clip_image002

Hope it helps and Happy CRMing!

ABOUT THE AUTHOR:

clip_image001

Twitter: https://twitter.com/msdynamicsblog
LinkedIn: https://www.linkedin.com/in/deepesh-somani-00296932

Google Play Store:

https://play.google.com/store/apps/details?id=com.dynamicsofdynamicscrm.msdynamicsblog&hl=en

Microsoft Dynamics CRM

{Dynamics 365 Enhancements} Add Notification Recommendations to your Entity forms using script

This blog is part of the series which I will use to cover all interesting enhancements coming in Dynamics 365.

Scenario: On Account form, if user fills in the Telephone field – suggest a recommendation to set Contact preference by Phone field. If user selects yes, set Contact by Phone option to allow.

Scenario by Graphics:

· On change of phone field, CRM shows a recommendation tooltip:

clip_image001

· When you click the information icon, CRM gives you a recommendation:

clip_image002

· If you pick Apply, CRM will do the updating to the field as required:

clip_image003

Great isn’t it?

Here is the link describing the new Client side scripting function: https://msdn.microsoft.com/en-us/library/gg334266.aspx#BKMK_addnotification

And here is the script for this one (Register it on change event of Phone field):

function addPhonePreferenceNotification() {

var myControl = Xrm.Page.getControl(‘telephone1’);

var telephone= Xrm.Page.data.entity.attributes.get(‘telephone1’);

var phonePreference = Xrm.Page.data.entity.attributes.get(‘donotphone’).getValue();

if (telephone.getValue() != null) {

var actionCollection = {

message: ‘Set the Contact Preference for Phone to Allow?’,

actions: null

};

actionCollection.actions = [function () {

Xrm.Page.data.entity.attributes.get(‘donotphone’).setValue(false);

myControl.clearNotification(‘my_unique_id’);

}];

myControl.addNotification({

messages: [‘Set Phone Preference’],

notificationLevel: ‘RECOMMENDATION’,

uniqueId: ‘my_unique_id’,

actions: [actionCollection]

});

}

else

console.log(“Notification not set”);

}// JavaScript source code

Hope it helps and Happy CRMing!



Check this out

ABOUT THE AUTHOR:

clip_image001

Twitter: https://twitter.com/msdynamicsblog
LinkedIn: https://www.linkedin.com/in/deepesh-somani-00296932

Google Play Store:

https://play.google.com/store/apps/details?id=com.dynamicsofdynamicscrm.msdynamicsblog&hl=en

Microsoft Dynamics CRM

{Dynamics 365 Enhancements}New Visual Designer for Business Process Flow in Dynamics 365

This blog is part of the series which I will use to cover all interesting enhancements coming in Dynamics 365.

In Dynamics 365 we have new visual designer for Business Process flows.

Here is a walkthrough for Business Process flow:

· Creating a new Sales Process on Lead entity:

clip_image001

· New editor will open up:

clip_image003

· Add Step to add further fields after selecting a Stage:

clip_image004

· After adding multiple steps in the stage, It will appear as below:

clip_image005

clip_image007

· For Adding a conditional branch Select +Add button and choose Add Condition:

clip_image008

· A + Tile will appear, Click on it:

clip_image009

· A condition box is visible (Right arrow is if condition is true part flow, wrong arrow shows condition is false part flow):

clip_image011

· Selecting true conditional flow:

clip_image013

· Click Add Stage to add a stage:

clip_image014

· Finally, will appear as below:

clip_image016

Want to document this?

No worries, just hit the snapshot button:

clip_image017

And here is an image for documentation available downloaded for you:

clip_image019

Great stuff Microsoft!

An old colleague of mine and well known Blogger on CRM Nishant has done a step of step for the new visual editor for Business rules here:

https://nishantrana.wordpress.com/2016/11/02/new-visual-designer-for-business-rules-in-dynamics-365/

Hope it helps and Happy CRMing!



Check this out

ABOUT THE AUTHOR:

clip_image001

Twitter: https://twitter.com/msdynamicsblog
LinkedIn: https://www.linkedin.com/in/deepesh-somani-00296932

Google Play Store:

https://play.google.com/store/apps/details?id=com.dynamicsofdynamicscrm.msdynamicsblog&hl=en

Microsoft Dynamics CRM

{Dynamics 365 Enhancements} Social pane improvements in Dynamics 365

This blog is part of the series which I will use to cover all interesting enhancements coming in Dynamics 365.

One of the most common requirement that is asked for CRM Social pane was ability to be able to order by different dates on Activity part of the social pane.

Let us have a look at Dynamics 365 social pane:

clip_image001

Notice the highlighted element available as an arrow on the social pane. This control now lets you order based on dates available on the activities.

What if I want to change it? Well you can. Just go to form editor, double click notes control and select Activity wall tab:

clip_image002

Great stuff, keep following to explore more interesting topics in Dynamics 365.

Hope it helps and Happy CRMing!



Check this out

ABOUT THE AUTHOR:

clip_image001

Twitter: https://twitter.com/msdynamicsblog
LinkedIn: https://www.linkedin.com/in/deepesh-somani-00296932

Google Play Store:

https://play.google.com/store/apps/details?id=com.dynamicsofdynamicscrm.msdynamicsblog&hl=en