Re: can ADD_LINE_ITEM table be duplicated??
by 105 » Thu, 29 Oct 2009 07:50:19 GMT
aggelis wrote:
I am assuming you are using FM10
=/- was a typo, it was meant to be +/-
It was unclear whether you were using 2 source tables (products and
services)
- if you were using 2 source tables, a (source) type field in the
invoicelineitems table would be worthwhile
- now that it is clear you are using one source (items) table, which
contains both products and services, a 'type' field (values: prod, serv)
is probably optional, although I would suggest including it. A type
field in the lineitems table could be used for a filter to separately
subtotal services and products on the invoice, for example.
bts_ is just shorthand for 'behind the scenes'
bts_layoutname layouts are used in scripts etc, and are normally hidden
from the user.
there are different ways of creating new related records.
You can use an acrr rel, establish the appropriate key fields, and
create a related record via the acrr rel (either in a portal or single
field) . Which is probably what you are familiar with.
You can also grab the relevant id values, and appropriate data, into
variables ( eg $_inv $_item.... or $_invoice_id, $_item_id...; syntax
variations )
then have the script
- go to the bts_lineitems layout
- create a new record
- the invoicelineitem_id primary key will automatically enter (you have
the key appropriately defined?)
- hard code the lineitems::invoice_id ( = $_invoice_id)
- hard code the lineitems::item_id (= $_item_id)
hard code the type (if used) as prod or serv (from another variable...
- etc (etc can be using lookups to enter cost.. or parse these into
variables as well
- then return to the invoice layout, commit/refresh
The advantage of using a go bts_layout is one less dedicated
relationship. Both approaches achieve the same result. I used to use
acrr, now I routinely use the go bts_layout approach.
If you use the parse into variables approach, use $ (local) and not $$
(global) variables; $ variables automatically clear there values once
the script has completed. Be clear and consistent with naming variables;
think about another developer looking at your script, or even yourself 2
years down the track; how obvious are the names?
example $_inv, $_inv_id , $_invoiceID, $_invoice_id
pick a pattern and generally type to stick to it; sometimes one has to
be prgmatic rather than dogmatic, but generally try to be consistent in
naming patterns (same applies to fields, table names...)
It always takes a while for the basic processes to become familiar
vaggelis; we have all been through it :-) It is easy to get swamped
with the details, think about the process e.g.
- parse relavant values to variables
- go line items layout
- new lineitems record
- hard code details from variables to line items record
- return to parent invoice record
It will come together, keep at it.
regards
Chris