Invoice Items Auto Numbering

Hi Community ))

I have an issue I failed to find the solution for. When I start an invoice I wish to have Invoice ITEMS automatic numbering in an invoice, starting from “1” up to whatever items there could finally be in an invoice.
Could you please advise on how to achieve it?

Hi,

you can create a code to count in each row the number of items of that particular cart and customer and add to 1.

ex: count(select(TABLE? [ID?], AND ([CART]. [_ THISROW]. [CART],…))) + 1

remember that with this code they will be counted in order of sync

Serial Numbers, If You Must Tips & Tricks ?

Danger Ahead! In general, sequential numeric identifiers (i.e., serial numbers) are risky in AppSheet: if two users happen to add rows at the same time, both rows could be assigned the same serial number, which could lead to confusion (at the least) or data loss (at the worst). For this reason, serial numbers are strongly discouraged! Basic Serial Numbers One way to implement serial numbers is with a normal (not virtual) column named (e.g.) Serial of type Number and an Initial value expression …

2 Likes

Thanks for your explanation. Could you please let me have a more detailed script?

Saverio_Soreca:

count(select(TABLE? [ID?], AND ([CART]. [_ THISROW]. [CART],…))) + 1

TABLE? [ID?] - Is it the table we have to create a “Count” column in?> Or it should a parent table instead?

Can it be a virtual column?

[CART] ? - You mean it should be an Order Id (in Order Item table?)…

I got lost actually…

I would need the columns of the table to explain better

right, but I think there is a more complex solution using the datetime. it might be useful

Ok, let me have a couple of seconds

The last columns:

I’ll explain the more complex process to avoid that the rows could be assigned the same serial number.

creates a (non-virtual) column of datetime type es. “sort” (ignore seconds disabled)

then create a virtual column with COUNT(SELECT(ORDER ITEM [ORDER ITEM ID], AND ([ORDER ID] = [_ THISROW]. [ORDER ID], [SORT] <[_ THISROW]. [SORT]))) + 1

now create a behavior (not display) in order item: set the values ​​…

column “sort” = NOW()

in order item_form (ux) insert the behavior as when form saved

template
<<Start: ORDERBY(SELECT(ORDER ITEM[ORDER ITEM ID],[ORDER ID] = [_ THISROW].[ORDER ID]),[SORT])>> <<[VC]>> <<…>>…

@Marc_Dillon what do you think about it?

Thanks a lot Saverio,

I will try to follow your instructions tomorrow, hopefully it will work out - still I am not sure if I can cope with it …

Have a nice weekend )

Of course! take it as a reference and modify the reference columns to your liking

Saverio_Soreca:

@Marc_Dillon what do you think about it

About what?

@Marc_Dillon regarding this method

Dear Saverio,
Thanks a lot !!! It works

1 Like

I just don’t see yet where to use you “Start expression”:

template
<<Start: ORDERBY(SELECT(ORDER ITEM[ORDER ITEM ID],[ORDER ID] = [_ THISROW].[ORDER ID]),[SORT])>> <<[VC]>> <<…>>…

It might be useful to generate multiple PO orders / Task / Mails / etc when you have o split an invoice to as many suppliers as you have items in your invoice grouped by those suppliers…
Thanks a lot once again, let’s keep in touch ))

I created the template script for you in case you wanted to generate a pdf

Saverio_Soreca:

regarding this method

Do I have to read this entire thread, or can you just point me to one post?

2 Likes