Sublist Item No doesn't update when items removed

Discussion created by GarethJ1 on Dec 18, 2018
Latest reply on Dec 21, 2018 by PiusW

Hi everyone


I have a SharePoint form for recording expenses, which uses a sublist to hold the individual items for the monthly expenses.  The sublist automatically numbers each item and there is also a total expenditure field that holds a sum of all items in the sublist:



This works fine when items are added but if I remove an item from the sublist, the Item No field is out of order:



To automatically calculate the item no I use two lines of code.  The first is set to run on form load:

window.lastPositionNumber = [[@SubLists.Monthly_Items.Item_x0020_No.Max]];



The second is used as the calculated expression for the Item No field:



I can see that my code doesn't take into account if an item is deleted from the sublist, but I wondered if this is possible?  I'm not sure if there is a way I can test for whether an item has been deleted and then recalculate the item numbers accordingly?


I'd be grateful for any advice anyone could give.  Thanks in advance.