AnsweredAssumed Answered

Script problem

Question asked by Gengis on Sep 8, 2009
Latest reply on Sep 17, 2009 by mrvodka


Script problem



I hope this isn't too confusing but...

I have been trying to find the problem with a script that using subscripts, first checks for unbilled items (time and materials) if it finds unbilled items it then creates a new invoice, setting the _kf_job Id field from a script parameter on the new invoice, Then taking the new _kp_invoice Id as a set variable, it then gets the description, cost, hours, and tax rate etc. again as set variables  first from the timeslips and then the supplied materials tables and creates new records in the invoice line items table and is supposed to set the foreign key field for the _kf_ invoice Id . It then sets the invoice line item id as a variable and puts this in the foreign key invoice line item field on the time or material record to avoid it being billed again.

What I get is a new record with Id and a job Id in the foreign key job Id field, but a related field  customer name is blank and no items appear in the invoice line items portal on the new invoice layout

The weird thing is that all the new records are in the  invoice line items table and are complete except for the new invoice Id, also when I check the relationships between the invoice and the job file tables just opening the relationships box seems to trigger the customer name field and when I return to the new invoice layout the customers name is there.

If I set the _kf_invoice Id field on the invoice line items table manually then the items appear in the portal. I have checked for any type errors in the set variable names but it all seems okay, I have also checked all the relationships between the tables and it seems correct , it all works fine if I do it manually.

The script was not my own invention I have adapted it from the script in the Missing manual book (Filemaker Pro 9) and again I have checked what I have done compared to the book and it seemsto be okay.

Any ideas?