I'm trying to figure out the logic behind this solution, and need some help. I've have an InfoPath form connected to one of my SP lists, and everything works fine. The problem is that now I want to include NEXT and PREVIOUS buttons on my form, where users can immediately go to the next or previous record in the list without having to exit the form and enter it again. I've played around with the rules, but can't seem to get the form to advance (or step back) to the next (or previous) record. Have any of you that use IP dealt with this? How did you fix it?
There is no command in InfoPath to do this.
It might--might--be possible with some really convoluted rules. InfoPath list item forms load new items by refreshing the main data connection. (It's possible that this is only for "Manage Multiple List Item" forms, I don't remember 100%). Have a rule set the query fields on the main data connection, then refresh, and the new items will be loaded.
So for a next button, set the ID in the main data connection query field to the ID of the next list item, then refresh the connection.
The trick of course will be figuring out the ID of the next and previous items. IDs start sequential, but when items are deleted it creates gaps. You also need to figure out if you are at the first or last item. You will have to do this via a data connection back to the list. However, deriving next and previous ids from a normal list data connection is going to be nearly impossible in xPath, so instead of creating a normal list data connection, create two data connections via REST API: one for previous ID, and one for next ID. For the next ID, filter the REST so that ID > current item ID, sort ascending by ID, and set a rowlimit of 1. First item to come back is the "next" item in the list, so your next button sets the main data connection query field ID to that, then refreshes. Will look something like this:
[%your website%]/_api/web/lists/getbytitle('your list name')/items?$filter=ID gt [%current item ID%]&$rowlimit=1&$orderby=ID asc
For the previous item, the opposite: filter to ID < current item ID, sort descending by ID, rowlimit 1. Whatever comes back is the previous item. Something like this:
[%your website%]/_api/web/lists/getbytitle('your list name')/items?$filter=ID lt [%current item ID%]&$rowlimit=1&$orderby=ID desc
There will obviously be a lot of fleshing out to do, but that is the broad outlines of the only solution I can think of.