Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics CRM (Archived)

Generate product number automatically

Posted on by 790

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

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Generate product number automatically

    Glad that it worked for you.

    As for the using through workflow, refer to the Wiki

    https://github.com/hncrm/HNIdentifierGenerator/wiki/Generate-Identifier-with-your-entities

    The approach is the same.  Add the workflow action to your workflow and populate the two provided fields.  

    Using the example in the previous post,

    1.   Populate 'ID For Contact' in the Config field
    2.   Populate 'description' in the FieldName field

  • zmk Profile Picture
    zmk 790 on at
    RE: Generate product number automatically

    please note that when I create the Identifier record via (Settings -> HN Extensions --> Identifier) and choose the Reset option to "None" i get the error below :

    HN-CRM-Error.png

    I then choose another option then save then i choose "None" again then save.

    Hope that the JavaScript will work with no reset option.

  • zmk Profile Picture
    zmk 790 on at
    RE: Generate product number automatically

    thanks HN CRM, it worked :)

    Please could you also state how to use the solution thru Workflows.

    Best Regards,

  • Verified answer
    Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Generate product number automatically

    To use the Identifier Generator for pre-populating the Id via Form Load, follow the steps below.

    1.  Create the Identifier record via (Settings -> HN Extensions --> Identifier)

    • Populate the value for the Name attribute, say 'ID for Contact'.  Note this is the when referencing from the other entity.
    • Populate other relevant details for the Identifier generator needs. 
    • Ensure the Example attribute is populated when the Identifier record is created

    2.  Utilise the Identitifier in the entity

    • In the Form Editor for the required entity, add a Form Library reference to "hn_/Scripts/Identifier.js" (through Form Properties)
    • Add an Event Handler with the following properties populated
      • Library:      hn_/Scripts/Identifier.js
      • Function:   hn_GenerateId
      • Enabled:    Checked
      • Comma separated...:  'NAME of IDENTIFIER RECORD', 'NAME of ENTITY ATTRIBUTE'

    NOTE:  

    • NAME of IDENTIFIER RECORD:  is the name of the Identifier record created earlier.  In this example it is ID for Contact
    • NAME of ENTITY ATTRIBUTE:  is the attribute name of the entity required to assign the identifier.   If you want to record the Id to the Description attribute, simply put 'description'
    • Both parameters needs to be enclosed with double or single quotes.
    • Using the above example the result for the parameters is   'ID for Contact', 'description'

    Hope that helps.

     

     

  • zmk Profile Picture
    zmk 790 on at
    RE: Generate product number automatically

    HN CRM I want to use it on form load. Could you please post a link to a tutorial on how to configure this or mention the steps here.

    Thanks a lot.

  • Suggested answer
    prt33k Profile Picture
    prt33k 6,907 on at
    RE: Generate product number automatically

    Hi,

    This is possible if you rely on a web service to give you unique number from SQL sequence. Following component are required:

    1. A SQL azure instance. Here you need to create a SQL sequence with NO CACHE setting.

    2. A SQL Stored Proc which call the sequence and return a unique integer value.

    3. A REST based service hosted on azure. This will call the SP and return the integer. The service can be authenticated based on azure AD credential. You need to register it on AAD.

    4. The onload JS which will check if the formtype is create, it will then called the Azure service and populate the field with inteer value it receives.

    The only issue will be that suppose you create a form and you close it without saving then the sequence number will be 'used' and the next time you open the form you will get the next sequence. However it will ensyre that no number are ever duplicated.

    Thanks,

    Prateek

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Generate product number automatically

    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?

  • tw0sh3ds Profile Picture
    tw0sh3ds 5,600 on at
    RE: Generate product number automatically

    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.

  • zmk Profile Picture
    zmk 790 on at
    RE: Generate product number automatically

    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

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Generate product number automatically

    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.

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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,280 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,235 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans