Skip to main content
Nintex Community Menu Bar

How can I use the last Item ID in a new form?

  • Sep 22, 2017 2:01 PM UTC
  • 11 replies
  • 60 views
  • Translate All

Forum|alt.badge.img+7

I need to populate a field with a predefined title such as "CHG0001." The "1" being the ID for the item we are about to enter. So I believe I need to pull the ID from the newest item and add one to populate this field. 

Anyone have this before?

11 replies

Forum|alt.badge.img+14
  • Scholar
  • Sep 22, 2017 5:24 PM UTC

have a look on this blog  

Translate

Forum|alt.badge.img+7
  • Author
  • Rookie
  • Sep 22, 2017 7:58 PM UTC

This is really good. However, these numbers aren't consecutive. 

How would I guarantee consecutive number?

Maybe, subtract 1 from the outcome? 

thoughts?

Translate

Forum|alt.badge.img+13

Hmm, what is the use case that requires this to be populated on the form? Why not just not have this field appear on the "New" form and then you can set the field with workflow, and show the field in "Edit" and "Display" modes?

Translate

Forum|alt.badge.img+7
  • Author
  • Rookie
  • Sep 22, 2017 8:09 PM UTC

I have thought about that. It would be easy just to build this field on create, but it's a requirement to have this show as a user is submitting the request. 

Translate

Forum|alt.badge.img+7
  • Nintex Partner
  • Sep 23, 2017 11:40 AM UTC

Hi,

Create a field name "ToQuery" with default value "X".

Use the following formula in a calculated value:

Max(Lookup("ListName","ToQuery","X","ID",TRUE)) so you will get the max ID in the list.

TRUE is used to return multiple values in an array.

Am not aware of the strongly typed values.

Translate

Forum|alt.badge.img+14
  • Scholar
  • Sep 24, 2017 7:39 PM UTC

what you mean with they are not consecutive?

solution is based on by sharepoint generated item ID, which is definitely consecutive.

Translate

Forum|alt.badge.img+14
  • Scholar
  • Sep 24, 2017 7:42 PM UTC

if this is the only reason, then I'd rather try to convince users/project owner that this is not the way how sharepoint works.

creating customized IDs just after an item is submitted is much simpler and straightforward solution.

Translate

Forum|alt.badge.img+7
  • Author
  • Rookie
  • Sep 25, 2017 12:00 PM UTC

the method you suggested causes the actual numbers to skip every other one. Because as you stated SharePoint generates the ID so with this method you create one to get the ID to the page, then you delete it. Therefore, you have a number on your page now (i.e.CHG1 ), but the one you are about to create is the next ID number (i.e. ID = 2). So when you create another request the new number generated for the page is the last ID + 1 making the new request number (i.e. CHG3). 1 and 3 are not consecutive.  

Translate

Forum|alt.badge.img+7
  • Author
  • Rookie
  • Sep 25, 2017 12:00 PM UTC

I will probably end up doing this, at least for now, but this is not a solution. Because it breaks the requirement.

Translate

Forum|alt.badge.img+14
  • Scholar
  • Sep 25, 2017 1:01 PM UTC

the point is, if you are going to generate IDs at the timepoint when an user starts filling in a form you can never avoid either gaps or duplicates.

therefore I suggested in the other post to wait until an item is submitted and just then assign it a custom ID based on item ID.

do not even rely on looking up for max existing ID, it's not reliable either.

Translate

Forum|alt.badge.img+3
  • Dec 6, 2017 10:06 AM UTC

Good idea ! happy.png . Thanks.

Translate