How to get the next ID from a SharePoint List - InfoPath Dev
in

InfoPath Dev

How to get the next ID from a SharePoint List

Last post 06-30-2014 03:37 PM by Hilary Stoupa. 3 replies.
Page 1 of 1 (4 items)
Sort Posts: Previous Next
  • 10-11-2010 07:31 AM

    • andy_t
    • Not Ranked
    • Joined on 10-10-2010
    • Posts 9

    How to get the next ID from a SharePoint List

    I have a data connection to a SharePoint list that will retrieve the last node and display the value of the "ID" field.  My question is how can I retrieve the value of the "next" record ID?  Exspecially when some records have been deleted.

    Example List:
    [ID]   [TITLE]
    1     First Record
    2     Second Record
    5     Third Record   (assuming records #3 and #4 were deleted)
          (records #6 thru #8 were deleted)
    9    <<<<< this will be the next record number, and the value I'm trying to get

    Andy_T
    Technology Manager, Puget Sound Clean Air Agency
    Seattle, WA
  • 10-11-2010 10:37 PM In reply to

    Re: How to get the next ID from a SharePoint List

    You can't rely on it because multiple people can be writing to SharePoint at the same time.

    You need to first submit your form and then requery it using a SharePoint list adapter (in the same form) and get the ID by filtering on some other unique attribute (filename or title?).  Then set the ID into the form and resubmit it. In other words, your submit button executes a bunch of rules: initial submit, query item, set ID and second submit. It only has to do the first three actions if the ID is not previously set. Not hard to set up but counterintuitive.

    Best of luck!

    Patrick Halstead
    Project Manager at Qdabra
  • 06-30-2014 01:13 PM In reply to

    Re: How to get the next ID from a SharePoint List

    Ok this is weird, So my Max(@ID) is stuck at 39 no matter even if 40,41,42.. are created. I couldnt figure it out no matter what when i realized the default view shows only 30 items in pagination. So the last item of the page was 39, considering some deleted items and skipped IDs like 1,2,5,7,8,9...34,,37,39 made 30 items on the page with last ID as 39. and thats all that Max function pulled from list. Moment i changed the default view to show more items, say 1000, now its working fine and grabbing new id on max(@ID) everytime, which brings to interesting question: do Infopath default sharepoint receive data connection get items from default view url or complete SPListItemCollection?
  • 06-30-2014 03:37 PM In reply to

    Re: How to get the next ID from a SharePoint List

    Hi - InfoPath uses the default view of your list unless you are using query fields to return specific items. I think you can get all items with an owssvr.dll connection (SharePoint 2007) or REST (SharePoint 2010 and 2013) if you want to leave your view alone....

    Hilary Stoupa

Page 1 of 1 (4 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.