Notifications
Announcements
No record found.
Hello
Any idea how to generate product number automatically.all solutions i have found populate ids on create event ,i need something to create id on the form load event.
*This post is locked for comments
You can create your own solution and use webapi to generate the next autonumber. The main issue with this, is that while you are on the form waiting to save it, other users might need to generate the next autonumber. Since you have not yet saved the autonumber you might have duplicates.
If you decide to modify the autonumber entity with the next autonumber when you retrieve it, if you cancel your current record and don't save it, your autonumbers will be out of sync.
This is the reason most solutions that populate autonumbers are based on the create event, since at that point we can confirm the record is created.
My suggestion would be to create a Configuration entity and have fields like Index into it and the number by which the iteration should increase.
Then, have a plugin on Pre-create of the Product to pick the number from configuration entity, add it to Product, increment and update the Configuration entity.
The config entity can be reused for other entities as well for auto-number generation is you make it that generic like storing the entity name, field name, index and increment by. The entity can then store multiple configurations for several other entities who want to use auto-number. Hope this was helpful too.
Really bad idea. Can you explain why you want this number on form load?
Pawel the auto number i want to generate is the product id on the product form which is set to be "system required".The user wants it automatically applied and since i need to fill it before saving i asked my question. I know a lot of managed solutions that create autonumbers but all works on the create event on the server side which is not applicable regarding this field.
Hi zmk,
As both Pawel and I mentioned, this is a bad idea and practice. You should go back to the business managers and explain this issue. If this is a must, the logic I mention above should work, or you can force a save when the record is created, so that the autonumber is generated.
Ok, now it's clear for me. You don't have to fill this field before creating record, simply make it disabled (or even invisible on form type Create) and you will not have to fill it. After creation it will be filled with any autonumbering solution that you choose.
Have a look at Dynamics 365 Identifier Generator available from github.com/.../HNIdentifierGenerator. It supports generation of the auto number both before or after the entity is created.
Pawel the field is system required so even if I disable it or hide it the system will says "The product number cannot be null"
HN CRM the solution is generating the following error:" DateTime is less than minumum value supported by CrmDateTime" Moreover where do I specify the entity name?
Thank you all for replying
You do not differentiate between server and client validation. This field is system required and this cannot be changed, and out-of-the-box when you try to save the form you get the JS message that you need to fill this field. Now, when you disable this field you will no longer get the message that this field is required - you will get a message from SERVER validation logic that this field is required. If it's server validation then most likely if you fill this field during Pre-Operation (I believe that Pre-Operation will be anough, but you can always go with Pre-Validation) you will not get this error message and your Product will be saved. I think that you should write your own autonumbering, it's a one-day job and you will have reusable solution for other entities.
Can you describe the steps to replicate the issue in the Issue log on Github.
As for specifying the entity name, it depends on how you are using the generator, via client side through Form Load or Workflow?
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.
As AI tools become more common, we’re introducing a Responsible AI Use…
We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…
These are the community rock stars!
Stay up to date on forum activity by subscribing.
SA-08121319-0 4
Calum MacFarlane 4
Alex Fun Wei Jie 2