Greetings all, admitted newbie here slogging through creating my first set of extensions in BC.
I created a couple of tables to calculate commissions and need to move data from one to the other when an invoice is created from an order. The 2 tables are "Order Commissions" and "Invoice Commissions" Both files have the same setup with 2 field keys (Order No/Seq and InvoiceNo/Seq) I have the logic all figured out on taking 1 Order Commissions record, changing the order number to Invoice Number, and inserting the record into the Invoice Commissions table. Invoice commissions table has 2 extra fields, #7 for storing invoiced amount, and #8 for Commission calculated.
So the issue at hand is an order might have more than 1 order commissions record. I've been experimenting with "Order Commission.findset(false, false) as a record reference expression, but I only seem to hit 1 record. How can I get this code to loop through multiple records in the Order Commissions table?
Code shown below:
I should point out that my question is flawed and I didn't realize it. Both tables I am talking about have a single key, but both of the keys are 2 fields: Order No/Seq and Invoice No/Seq. I have attached my procedure to an event that passes both of the numbers to my function. The gist of the issue is:
How do you read a record from one file, swap the order number for the invoice number, and write that record to another file?
You can gett a record by using the function GET just like
Customer.GET("10000"); //# where the primarykey is Customer no. 10000
Customer.MODIFY(TRUE); //# You can save a modified record using this command. The parameter TRUE executes the code in the MODIFY-trigger
Customer.VALIDATE(Name,"A new Customer Name"); //# You add a new value to a field using Table.VALIDATE(FIELD,NEW_VALUE);
If a primary key of a table consist of more than one field then you can do two things either use the GET function or a FIND/FINDSET/FINDFIRST/FINDLAST
SalesHeader.GET("Document type"::Order,"1000"); //# OR
SalesHeader.SETRANGE("Document Type","Document Type"::Order);
Awesome! I had to switch over to a different language for another project (VBA inside Excel anyone?) I will look at this on Monday and see if it is my salvation. Thank you.