Skip to main content

Notifications

Microsoft Dynamics CRM (Archived)

how to increment a value in a related entity for the sake of autonumbering

Posted on by Microsoft Employee

Hello, I have spent a couple of hours trying to figure out how to define a workflow that creates an autonumber.  (Ultimately, I wish to create a unique barcode for each record in an entity.)  I have reviewed multiple links, but so far I can't figure out what was actually done to make it work.  Can someone give me a little help?  (BTW, we use CRM 2011.)

We have an entity.  Let's call it Entity 1.  I added a barcode field.  For the existing records I created barcoded values that look like this: *10001*, *10002*, etc.  The workflow that I wish to create would create a unique barcode when any new record is inserted into Entity 1.

Following several examples I have seen online, I created another entity.  Let's call it Entity1_Autonumber.  I added three fields: Prefix, Count and Suffix.  Prefix and Suffix are text fields of length 1.  The count field is a whole number.  For Entity1_Autonumber, I defined a 1:N relationship back to the entity that I wish to store the autonumber (i.e., Entity 1).


I created a form for Entity1_Autonumber.  I added a single record.  Prefix gets '*'.  So does the Suffix field.  The count is defined as 10042.  (This is the last number for the barcode field in Entity 1.  Using my data so far, the last barcode is *10042*.  When I create a new record in Entity 1, I want the barcode field to be populated with *10043*.)

Now for the fun part.  I created a Process/workflow.  The entity for this work flow is Entity 1.  The workflow is designed to run when a new record is created for Entity 1.  I add a new step.  I choose "Update."  I also choose the related entity (Entity1_Autonumber).  My purpose is to first increment the Count field for Entity1_Autonumber, then build a new barcode and make sure the created record (in Entity 1) receives it. 

I set the properties for this step.  The three fields for the related entity appear on the left.  (They are: Suffix, Count and Prefix.)  The fields are blank.  On the right I have the "Form Assistant."  At this point I am mystified.  How do I increment the count field by one?  I can use the Form Assistant and put the name of the field in the Count text field.  But I can't figure out how to add a "+ 1" anywhere.

So far I can't finish the step of incrementing the related Entity1_Autonumber Count field.  This is step 1.  I would still need to figure out how to take the new count field and stick it into the Barcode field for Entity 1, along with the leading and following asterisk.

Can someone out there lend a hand?  I should think that a definitive reference for defining autonumbers that even a CRM newbie using an old version of CRM would be of value to this community.  So far I cannot follow the solutions that have been offered.

Any help is greatly appreciated.

 

*This post is locked for comments

  • Drew Poggemann Profile Picture
    Drew Poggemann 9,079 on at
    RE: how to increment a value in a related entity for the sake of autonumbering

    Sorry, right.  This needs to be synchronous to work, async will not cut it!  

    Agreed, should have auto-numbering.  It is there for some entities with ability to even configure but not there for all which should be an option that should just exist (with ability to map format of numbering sequence).

    I will think about other options for you...

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: how to increment a value in a related entity for the sake of autonumbering

    Hi Drew, thanks for your reply.  I have encountered the first link before; it seems that any autonumbering in CRM 2011 is unreliable because of its asynchronous nature.  However, it would be helpful if "survivingcrm" would describe each step in the three-step workflow with greater detail.  I have tried similar steps but nothing works for me in CRM 2011.

    As for the second link, it doesn't make sense for us to use a plugin.  This is because we would be separating our business logic in multiple places, as opposed to sticking with workflows.

    However, thanks again for the reply and contributing to our understanding of this needed functionality in CRM.

    BTW, auto-numbering is available in Microsoft Access and SQL Server.  I wonder why it is not available out of the box to CRM users.  Even more, I wonder why workflows attempting to replicate this functionality simply don't work--without any error messages--in CRM 2011.  Admittedly, this is an old version of the software.  However, this is Microsoft, not some start-up company.

  • Suggested answer
    Drew Poggemann Profile Picture
    Drew Poggemann 9,079 on at
    RE: how to increment a value in a related entity for the sake of autonumbering

    Hi Scott,

    Looks like you are really looking for an auto-numbering routine for what you are doing here.  I have implemented this a couple of times for customers following the techniques here:

    survivingcrm.com/.../auto-numbering-workflows-real-time-vs-asynchronous

    and we specifically implemented the following that is discussed here:

    community.adxstudio.com/.../adxstudio-auto-numbering-workflow-helper - although now packaged with other tools.

    I think this will get you to what you are trying to accomplish (I hope).

    Thanks much,

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: how to increment a value in a related entity for the sake of autonumbering

    OK, rather than starting a new thread, I think the administrator(s) of this forum would probably prefer if I keep on adding to this one.

    There are two things I wish for a workflow to do:

    1. increment the value of a field in a related entity.

    2. post the value of this field in the entity which is having a record created.

    I haven't got either task to work.  I am particularly perplexed that I can't get the value of the field in question to even appear in the record being created.  This is despite many commentaries online showing how it works for others.

    For the moment, I wish to focus on just #2 above.  I wish to display the value of a field in a related entity.  Here are the steps I have tried:

    I have an entity.  ("Entity 1".)  This is the entity where I wish to populate a barcode with a unique number every time a new record is created.

    I created a second entity.  ("Entity1_Autonumber".)  I added a form.  I entered a single record.  I gave the count field a value (10042).  I defined a 1:N relationship with the second entity and the first.

    I created a process.  I indicated this is for Entity 1.  I created a step.  I chose "update record."  My belief is that the record will be created and this process will kick off.  For the step, I clicked "set properties."

    A new window appears.  I put my mouse in the barcode field.  I went to the Form Assistant.  I set these values:

    Operator: Set to

    Look for: I selected the second entity.

    In the control below the "look for" I selected the field that I wish to carry over to the new record.

    Click "Add."  

    Click "OK".

    Yellow text appears in the field that I wish to populate.  I save the workflow.  I then Activate it.  Then I "save and close" the open windows.

    BTW, I'm doing this all in Internet Explorer.

    To test the workflow I create a record in Entity 1.  Then I run a query in SQL to see if the field that I wish to have populated from the related field has any value.  It doesn't!  The field is always empty.

    Does anyone have any advice?  All help is appreciated.  Thanks.

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: how to increment a value in a related entity for the sake of autonumbering

    Mike, good idea.  However, we are trying to keep our business logic confined to workflows.  This is to centralize our programming.  Thanks for the reply, though.  :)

  • st738407 Profile Picture
    st738407 225 on at
    RE: how to increment a value in a related entity for the sake of autonumbering

    Our organization does not trust the increment fields in the workflow (we have had a lot of miss counts), so we ended up putting our auto numbering into a plugin, similar to the logic you described, with an Autonumber entity to hold the values.

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: how to increment a value in a related entity for the sake of autonumbering

    So far my steps in this work flow are:

    (Upon create record)

    step 1: Increment the value of the count field in my related entity.  (Entity1_Autonumber).  Status: Does not work.

    step 2: In the barcode field that I need to fill with a new value, put the prefix (i.e., a single asterisk) from the related entity. (Entity1_Autonumber).  Status: Does not work.

    step 3: In the barcode field, append the existing value with the new count value. Status: Does not work.

    step 4: In the barcode field, append the existing value with the suffix from the related entity.  Status: Does not work.

    Instead of a forum, perhaps Microsoft needs to start a suicide hotline for developers trying to customize CRM 2011.  

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: how to increment a value in a related entity for the sake of autonumbering

    Gary, you resolved my problem with the CRM not saving my workflow logic.  However, I have finished defining the work flow and it doesn't work.  I will gladly mark your answer as "verified" if I could only get this work flow to actually do what it is supposed to.

  • Suggested answer
    Gary Letter Profile Picture
    Gary Letter 1,267 on at
    RE: how to increment a value in a related entity for the sake of autonumbering

    Some of those little "bugs" you find turn out to be browser compatibility issues.

    Please mark the answer as Verified if it resolved the issue.

    Thanks!

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: how to increment a value in a related entity for the sake of autonumbering

    Gary, thanks!  I thought I was using IE.  (I was using Chromium.)  With IE, my changes to step 1 were saved upon returning to the workflow.

    I wouldn't think that CRM would be browser-specific.  However, it certainly is.

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!

Community AMA December 12th

Join us as we continue to demystify the Dynamics 365 Contact Center

Leaderboard

#1
André Arnaud de Calavon Profile Picture

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

#2
Martin Dráb Profile Picture

Martin Dráb 230,188 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans