rappen / AutoNumManager

XrmToolBox plugin to manage Auto Number attributes in Microsoft Dynamics 365
http://anm.xrmtoolbox.com
GNU General Public License v3.0
9 stars 7 forks source link

Seed number guessing is out #86

Closed mmfc closed 1 year ago

mmfc commented 1 year ago

Appreciate the seed number guessing is probably not 100% accurate, however it seems way off - I just updated 3 tables with a new auto number, and used your trick with a separate entity to update the autonumbers, however when re-setting the seed to the next value (as I massively underestimated it initially), the ANM guessed value was about 50 - 500 records out.

Whereas when I sorted the autonumber column A-Z, it was clear there were higher numbers than the guess.

Example at the lower end A-Z sorted Auto num image

Autonum guess image

Example at the higher end A-Z sorted Auto num image

Autonum guess image

rappen commented 1 year ago

Hi Sorry for the late response, and sorry this code was made long ago... You might look at this code where the guessing is done: https://github.com/rappen/AutoNumManager/blob/master/AutoNumMgr.cs#L479-L529

Let me know if I have to fix this, or if you have any ideas of a solution! 🙏

mmfc commented 1 year ago

No problem - I was more writing the issue so that others are aware than expecting a solution :)

Looking at your script, you sort by createdon - which would work in most cases, but I had followed your suggested trick to number existing records - which is where the issue has arisen as the new autonumbers weren't done in createdon order.

Depending on the format of the sequence number, it could be ordered alphabetically by the autonum attribute (which is how I found the largest one) - but I think that would fail where the format had a {RANDSTRING} portion before the {SEQ}?

So overall, the only way to fix it would be rather complicated/programmatically expensive (e.g. splitting the string to get only the sequence part, and then ordering based on that) and not worthwhile.