Accessing a single line item on an invoice
I'm trying to pull the TOTAL value of a single line item in an invoice that has 3 line items consisting of £195, £56, and £18.
After trying everything I can think of, I keep getting the totals for all the line items instead of just 1 i.e 195,56,18 appearing in my formula field.
Can anyone show a typical code example to do this (if it is possible)? Many thanks.
16 replies
-
Hi
How are you deciding on which line you want to see the total for.
Regards John
-
I am stuck in there as well. working on that for a week, no clue
-
In my case, is pulling the data from the Invoice. Also, I did try to pull the line item info from each invoice. You might try to aim at the item name I guess, or any unique info you are able to aim at.
My one look like this
let id := Id;
let type := 1; // The unique type I could aim at (I got 1-4 different type) //
let name := (select Payment where Id = id).'Name'.'Customers'.'Full Name';
"" + (select Payment where Type = type and Name.Customers.'Full Name' = name).AmountHope it could help
-
Can you post the code from the new table?
Can you let us know the relationship between the new table and Payments?
-
Roger said:
Fred It worked currently in the Summary table, but when I try to pull data in another table, it shows nothing. I'm a newbie in writing code, I thought maybe I confused and mashed up the data location and relationship in different tables, still working on it, hopefully, can solve it out.Sorry for not responding for so long. How are you doing with this topic?
Roger said:
let id := Id; let type := 1; // The unique type I could aim at (I got 1-4 different type) // let name := (select Payment where Id = id).'Name'.'Customers'.'Full Name'; "" + (select Payment where Type = type and Name.Customers.'Full Name' = name).AmountLooking at the above code, it looks like you are trying to show the data from the Amount field in the Payment table. An important thing to remember is that Ninox always returns an array when doing a select. Even if Ninox returns only 1 record.
So your last line:
(select Payment where Type = type and Name.Customers.'Full Name' = name).Amount
will not return anything because Ninox does not know what to do with the results of the select Payments. You need to tell Ninox to do an array function like first or last or concat. If you are only expecting one record you can use the first command:
first((select Payment where Type = type and Name.Customers.'Full Name' = name).Amount)
This will return data from the field Amount.
-
You can try this:
let id := 'Invoice Number'; let xRec := item((select Invoice where 'Invoice Number' = id), 3) let xCost := xRec.'Invoice Detail'.Cost let xItems := xRec.'Invoice Detail'.Items let xDesc := xRe.'Invoice Detail'.Description
What this does is at line 2 instead of only getting the data from the field Cost. We are putting the entire record into a variable. Now we can call whatever field is in that record.
Another example would be at the beginning. You could replace line 1 with:
let t := this; let xRec := item((select Invoice where 'Invoice Number' = t.id), 3) let xCost := xRec.'Invoice Detail'.Cost let xItems := xRec.'Invoice Detail'.Items let xDesc := xRe.'Invoice Detail'.Description
The this command pulls all the fields of the record you are on. Then you can later specify which field you want to use. In this case it is probably overkill to use this. But if you need to search on three or four different criterias then doing one line of this would be easier than four separate variables.
Content aside
- 2 yrs agoLast active
- 16Replies
- 405Views
-
3
Following