Solved

Reseting Primary Key / ID on Sharepoint 2013 list

Posted on 2015-02-13
4
1,307 Views
Last Modified: 2015-02-13
Hello - I need to know how to use a resetting key or field on a SharePoint list (that is accessed by Access 2013 as a table). Currently, the primary key (ID) does not reset to 0 when all records in the table are deleted. When it was an Access table, it would reset to 0, and a query would populate the table in a way that the ID would populate 1, 2, 3, 4.... Now while using the SharePoint list, the ID retains the last value and doesn't reset. The problem is that I have follow on queries that rely on this ID value starting at 0 each time. Since it doesn't reset the queries aren't running properly.

So again in summary, I just need an autonumber SharePoint list field to reset each time the table is completely deleted to 0 records, or a workaround using a ID that starts at 1 each time the table is loaded with new records (and no previous records).

Thanks,

Mike
0
Comment
Question by:maknit
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 85
ID: 40608235
When it was an Access table, i
Access does not do that unless you Compacted the database after the delete. I would assume you'd have to "compact" the Sharepoint list as well, or re-output the table to Sharepoint.

A bigger problem is that you're depending on an AutoNumber field to be sequential, and there is no guarantee of that. It's guaranteed to be unique, of course, but not sequential. You would be much better of redesigning your system to use a different ordering method. If you load your records in a specific manner, then the same method you use for that "specific manner" could be used to order the records afterwards. For example, if you load records sequentially based on a Date field, you could then make sure your queries and such use that same Date field to Order By when you're viewing them in a Form or Report, or when you're working with them in a Query.
0
 

Author Comment

by:maknit
ID: 40608271
Ok - thanks - I was thinking that would be a limitation of the SP Lists. The autonumber worked in the past because the query that loaded the table would sequentially load a fixed amount of date sorted records - worked every time because of this, and I believe another outcome wasn't even really possible as long as the date sorting of loaded data never changed. So the row num always matched the right record (actually a period number - think 1 - 12, a rolling 12 month set of monthly periods where period 1 is always the current month, and period 12 would be a year out from period 1).  It sounds like I'll need to basically manually set an id or sequence field to do the same thing the autonumber used to do, before the query runs. Not as simple as the current method, but probably doable. Thanks.
0
 
LVL 38

Accepted Solution

by:
PatHartman earned 500 total points
ID: 40608527
If the current month is always period 1, then you can calculate the value of the other periods based on their relationship to the current month.  The DateDiff() function using "m" as the unit should give you the period.
0
 

Author Comment

by:maknit
ID: 40608540
Thanks - that's a great idea.

It didn't let me select both solutions - but note that both comments from Scott McDaniel and PatHartman collectively make the solution.
0

Featured Post

Building an interactive eFuture classroom

Watch and learn how ATEN provided a total control system solution including seamless switching matrix switch, HDBaseT extenders, PDU, lighting control to build an interactive eFuture classroom.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Enabling the Skype for Business Meeting Scheduler in Hybrid OWA
This article describes how to import an Outlook PST file to Office 365 using a third party product to avoid Microsoft's Azure command line tool, saving you time.
Migrating to Microsoft Office 365 is becoming increasingly popular for organizations both large and small. If you have made the leap to Microsoft’s cloud platform, you know that you will need to create a corporate email signature for your Office 365…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…

628 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question