web
You’re offline. This is a read only version of the page.
close
Skip to main content
Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

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

(0) ShareShare
ReportReport
Posted on by

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

I have the same question (0)
  • Community Member Profile Picture
    on at
    RE: how to increment a value in a related entity for the sake of autonumbering

    Update: I think I have figured out how to update the related Count field by one.  In the workflow that I have created I click the "set properties" button for the same Step 1 described in the original post.  The same window that I described in the original post appears.  I put my mouse in the count field of the related entity (Entity1_Autonumber).  In the "Form Assistant" I choose the Operator drop-down.  I select "Increment by".  I put a 1 in the Default Value field at the bottom of the Form Assistant.  I click the OK button.

    On the left side, above the Count field, I see "Increment by".  In the control I see {1}.  It looks like I will now increment the count field when I create a record in the "Entity 1" entity.

    Unfortunately, the change won't persist.  If I click "save and close" on this step, then "save and close" for the workflow, I expect that my "Increment by" logic will be there when I return.  It isn't!  If I return to the work flow, click "set properties" again for step 1, I have a completely blank page without my "increment by" logic.  So, now I am wondering how to actually save and close this step of my work flow so that it remains when I wish to return to it.

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

    It sounds like you are following the correct steps. It might be a browser issue. Try switching to another browser, or follow the steps for IE below, and see if you get the same result:

    • CRM web site is in Trusted Sites or Intranet zone
    • CRM web site is exempted from pop-up blocking
    • CRM web site is in Compatibility View list
  • Community Member Profile Picture
    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.

  • Suggested answer
    Gary Letter Profile Picture
    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
    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.

  • Community Member Profile Picture
    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.  

  • st738407 Profile Picture
    227 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
    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.  :)

  • Community Member Profile Picture
    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.

  • Suggested answer
    Drew Poggemann Profile Picture
    4 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,

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…

Abhilash Warrier – Community Spotlight

We are honored to recognize Abhilash Warrier as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
HR-09070029-0 Profile Picture

HR-09070029-0 2

#1
UllrSki Profile Picture

UllrSki 2

#3
ED-30091530-0 Profile Picture

ED-30091530-0 1

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans