Skip to main content

Search

Increment number field in sublist

Comments

3 comments

  • Christof

    Hi Gareth Jayne

     

    I suspect  [[@SubLists.Credit_Card.Item_x0020_No.Max]] gives you the max of saved items. Since these items in grid aren't saved at this time, it will return not the item count you expect.

     

    Did you already tried to use a window variable for your counter?

     

    Just get the max one time, save it to the window variable and use it in your expression.

    0
  • Christof

    Found a solution. The key is not to get the max in the expression on sublistcolumn itself, since this triggers an endless loop (get calculated max of item's values you're changing right now).

     

    In the end it's not much code. Just configure these two expressions:

     

    Form Load Action Excute Script expression code:

    window.lastPositionNumber = [[@SubLists.SublistContacts.PositionNumber.Max]];

    Calculated Assignment expression on Sublist column:

    ++window.lastPositionNumber

     

    Did not find out why the numbers are shown with two decimals... after saving all is fine...

    0
  • GarethJ1

    Hi Christof

     

    Thank you very much.  As you say, that's a bit weird with the decimal places especially as I've set that field explicitly to be 0 decimals, however your code does exactly what I need.

    0

Please sign in to leave a comment.