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)

Generate product number automatically

(0) ShareShare
ReportReport
Posted on by 792

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

I have the same question (0)
  • Aric Levin - MVP Profile Picture
    30,190 Moderator on at

    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.

  • Suggested answer
    Priyesh Profile Picture
    7,396 User Group Leader on at

    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.

  • tw0sh3ds Profile Picture
    5,600 on at

    Really bad idea. Can you explain why you want this number on form load?

  • zmk Profile Picture
    792 on at

    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.

  • Aric Levin - MVP Profile Picture
    30,190 Moderator on at

    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.

  • Suggested answer
    tw0sh3ds Profile Picture
    5,600 on at

    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.

  • Community Member Profile Picture
    on at

    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.

  • zmk Profile Picture
    792 on at

    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

  • tw0sh3ds Profile Picture
    5,600 on at

    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.

  • Community Member Profile Picture
    on at

    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.

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