Breaking news from around the world
Get the Bing + MSN extension
Choose your path Increase your proficiency with the Dynamics 365 applications that you already use and learn more about the apps that interest you. Up your game with a learning path tailored to today's Dynamics 365 masterminds and designed to prepare you for industry-recognized Microsoft certifications.
Visit Microsoft Learn
2019 release wave 2 Discover the latest updates and new features to Dynamics 365 planned through March 2020
Release overview guides and videos Release Plan | View virtual launch event
Ace your Dynamics 365 deployment with packaged services delivered by expert consultants. | Explore service offerings
Connect with the ISV success team on the latest roadmap, developer tool for AppSource certification, and ISV community engagements | ISV self-service portal
The FastTrack program is designed to help you accelerate your Dynamics 365 deployment with confidence.
FastTrack Program | Finance TechTalks | Customer Engagement TechTalks | Talent TechTalks | Upcoming TechTalks
I want to get the total entity record count when a form is submitted and add that value to a field. I see how to get the record count for a report, but this is for a form.
I'm using D365 online version 9.x.
When a form is submitted/entity record is saved, write a CRM Async plugin on post- create message, do an aggregate fetchxml query to get the count & update the entity count attribute.
If you hit the max count limit, then you have to pull the records, paging cookie & calculate in a counter till last page to get the actual result.
You could use a rollup field if there is a relationship between the entity records and a parent entity, and get that count back on the child entity by a calculated field.
Or you can use a custom workflow activity according to this blogpost: How to: roll up without limitations
Plugin is the best options for increment the value to avoid redundancy. Let say if you write logic in client side and get total record count and at the same moment another user create record in the same entity you may get wrong value at client side. So write a create message , post operation plugin and in the plugin code get total record using FetHXML and set the value to the field to update.
You can also do this using workflow but in that case you need to maintain another entity to track the last number. Have a look my article , you may get some idea-
Why not use the standard auto number function of Dynamics 365 CE that can be based on a sequential number,
You can enable a existing or new field as auto number field.
Use to XrmToolBox plugin to set the field and its seed (begin number) for this
More info about the configuration: http://anm.xrmtoolbox.com/
You could do this in couple of different ways, but I am going to mention one that involves less work and performance wise a bit better approach
Assuming the created record has parent entity, you could add a roll up field to the parent entity to do the count and then you can have a quick view form on the child entity to display the total record count. It will update on an hourly basis just to make sure the system performance is not affected. But if you want the update instantly, you can manually or programatically force calculate a rollup field to get the number updated but this may affect the performance a bit.
Let me know if you need more info on this
Sorry that I didn't respond sooner. Your solution will work, but I need the calculation of the record count to be executed after the record is created, so I don't think this will work for me.
Sorry I didn't respond sooner. There is no parent entity involved with this process. Thanks for the suggestion.
Unfortunately, I can't use the auto number function as I need to query the total amount of records per day and not the total records. I didn't mention that in my description. Sorry for that.
Thanks for your suggestion. I used your solution and it worked.
Thanks Mike, pls accept the answer & close the thread to help future solution seekers.
For version 9.0
Business Applications communities