web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

How to get the total record count from an entity and put that value into a form field

(0) ShareShare
ReportReport
Posted on by 160

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.

Thanks

*This post is locked for comments

I have the same question (0)
  • Verified answer
    Arun Vinoth Profile Picture
    11,615 Moderator on at

    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.

    hihaj.com/retrieve-the-accurate-total-count-of-entities-via-dynamics-crm-web-api-6e777fae650d

    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.

  • Suggested answer
    StefanS365 Profile Picture
    3,575 Most Valuable Professional on at

    Hi there,

    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

  • Suggested answer
    gdas Profile Picture
    50,091 Moderator on at

    Hi ,

    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-

    goutamdascrm.wordpress.com/.../dynamics-365-auto-number

  • Suggested answer
    StefanS365 Profile Picture
    3,575 Most Valuable Professional on at

    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

    www.xrmtoolbox.com/.../Rappen.XrmToolBox.AutoNumManager

    More info about the configuration: http://anm.xrmtoolbox.com/

  • Kokulan Profile Picture
    18,054 on at

    Hi

    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

  • Z_Mike Profile Picture
    160 on at

    Stefan,

    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.

  • Z_Mike Profile Picture
    160 on at

    Kokulan,

    Sorry I didn't respond sooner.  There is no parent entity involved with this process.  Thanks for the suggestion.

    Mike

  • Z_Mike Profile Picture
    160 on at

    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.

  • Verified answer
    Z_Mike Profile Picture
    160 on at

    Arun,

    Thanks for your suggestion.  I used your solution and it worked.

    Mike

  • Arun Vinoth Profile Picture
    11,615 Moderator on at

    Thanks Mike, pls accept the answer & close the thread to help future solution seekers.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
SA-08121319-0 Profile Picture

SA-08121319-0 4

#1
Calum MacFarlane Profile Picture

Calum MacFarlane 4

#3
Alex Fun Wei Jie Profile Picture

Alex Fun Wei Jie 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans