Advertisements

{Dynamics 365 (ADX) portal Tips & Tricks} Show the top record from an entity view based using query filters in Dynamics 365 portals (ADX portals)

This is one more of my recent articles on ADX portals and this blog I am going to write on how to select the topmost record from an entity view using query filters.

Can’t depict the exact business scenario here but probably an example will get you started on how to get started with the query filters.

So let’s take an example here – What if someone asks you to print the the details of an employee with the highest salary from a specific view?

Let’s assume there we are leveraging the Contact table in CRM for Employee.

And the view I select is “Active Contacts” view.

Schema name of the salary field in the contact table – “new_salary”

In CRM, I created an Entity List called “Contact List” with a view “Active Contacts”

image

 

In the Portal side, in the Copy field just paste the below code.

{% entitylist name:”Contact List” %}
{%entityview logical_name:”contact”, name:”Active Contacts” %}
{% assign records = entityview.records| order_by: ‘new_salary’, ‘desc’%}
{% assign records2 = records| take: 1 %}

{% for record in records2 %}
Employee Name: {{ record.fullname }},  Salary: {{ record[“new_salary”]}}
{% endfor %}
{% endentityview %}
{% endentitylist %}

 

The code is pretty simple. I load the entity view “Active Contacts” from the Entity List “Contact List” that I created in the previous step.

The important part is the code highlighted in yellow.

I just take the output of view and then order by salary descending (default order is ascending) and in the next line I just take the top record from there.

That’s all. I now just print out the Employee Name and the Salary of the employee. Not a real world example but probably helps you get the idea.

 

-Debajit Dutta

(Dynamics MVP)

For training/ consulting please email at info@xrmforyou.com

Visit our products page – http://www.xrmforyou.com/products.html

Advertisements

About Debajit
I am a Dynamics CRM Most Valuable Professional (MVP) with 10 years of experience in Microsoft .NET Technologies and 7 years of dedicated experience in Microsoft Dynamics CRM. I have worked with companies like Microsoft, SanDisk, PwC, TMF Group and have extensive experience of implementing complex CRM solutions from both offshore and client side. Currently the face of XrmForYou.com with significant experience in delivering corporate training on Dynamics CRM and have already delivered multiple projects to client through XrmForYou.com Author of multiple tools on codeplex including the 'Role Based Views' and 'CRM-Sharepoint Metadata manager & Attachment Extractor' which are available for commercial use under XrmForYou.com For consulting/ training, drop me a note at info@xrmforyou.com or visit our website www.xrmforyou.com

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: