6 Replies Latest reply on Feb 24, 2013 9:15 AM by philmodjunk

    Problem set field in print script

      Title

      Problem set field in print script

      Post


           Here is my script for creating and then printing a deposit invoice. What I want, is to set field on another related layout depending in whether the customer has paid - I priovide the choice by a custom dialogue and subsequent if statements. I have tried adding this to the script after the choice if customer has paid, but it doesnt work...any ideas why?

           Go to layout ["Schedule"(invoice details)]

           Set Field [ INVOICE DETAILS::status; "Yes" ]

            

             
      •           Allow User Abort [ Off ]
      •      
      •           Set Error Capture [ On ]
      •      
      •           If [ INVOICE DETAILS::Deposit Created = "No" ]
      •      
      •           #Set up variables
      •      
      •           Freeze Window
      •      
      •           Set Variable [ $OriginalInvoiceID; Value:INVOICE DETAILS::ID_Invoice_pk ]
      •      
      •           Set Variable [ $order; Value:INVOICE DETAILS::fk_Order ]
      •      
      •           Set Variable [ $customerID; Value:INVOICE DETAILS::ID_Customer_Billing_fk ]
      •      
      •           Set Variable [ $DepositID; Value:INVOICE DETAILS::Deposit Amount ]
      •      
      •           Set Variable [ $Ref; Value:INVOICE DETAILS::Reference ]
      •      
      •           Set Variable [ $link; Value:INVOICE DETAILS::Deposit Link ]
      •      
      •           Set Field [ INVOICE DETAILS::Tax_Percentage; invoicedetails_PREF::Tax Rate ]
      •      
      •           Set Field [ INVOICE DETAILS::Tax Code; "Standard" ]
      •      
      •           Set Variable [ $VAT; Value:INVOICE DETAILS::Tax_Percentage ]
      •      
      •           Set Variable [ $VATCODE; Value:INVOICE DETAILS::Tax Code ]
      •      
      •           Set Field [ INVOICE DETAILS::Deposit Created; "Yes" ]
      •      
      •           #New Invoice details record
      •      
      •           New Record/Request
      •      
      •           #New Invoice record
      •      
      •           Set Field [ Invoices::fk_Invoice details ID; INVOICE DETAILS::ID_Invoice_pk ]
      •      
      •           Set Field [ INVOICE DETAILS::fk_Invoice; Invoices::Invoice Number ]
      •      
      •           Set Field [ INVOICE DETAILS::fk_Invoice Date; Invoices::Invoice Date ]
      •      
      •           Set Field [ INVOICE DETAILS::fk_Order; $order ]
      •      
      •           Set Field [ INVOICE DETAILS::ID_Customer_Billing_fk; $customerID ]
      •      
      •           Set Field [ INVOICE DETAILS::Deposit Amount; $DepositID ]
      •      
      •           Set Field [ INVOICE DETAILS::Reference; $Ref ]
      •      
      •           Set Field [ INVOICE DETAILS::Deposit Link; INVOICE DETAILS::ID_Invoice_pk ]
      •      
      •           Set Field [ INVOICE DETAILS::Deposit Link; $Link ]
      •      
      •           Set Field [ INVOICE DETAILS::Type; "Deposit" ]
      •      
      •           Set Field [ INVOICE DETAILS::Tax Code; $VATCODE ]
      •      
      •           Set Field [ INVOICE DETAILS::Tax_Percentage; $VAT ]
      •      
      •           Set Field [ INVOICE DETAILS::Deposit Created; "Yes" ]
      •      
      •           Perform Script [ “Copy Shipping to Shipping” ]
      •      
      •           Set Variable [ $InvoiceID; Value:INVOICE DETAILS::ID_Invoice_pk ]
      •      
      •           Freeze Window
      •      
      •           #Set up line items
      •      
      •           Go to Layout [ “Invoice Items” (invoicedetails_INVOICEITEM) ]
      •      
      •           New Record/Request
      •      
      •           Set Field [ invoicedetails_INVOICEITEM::ID_Invoice_fk; $InvoiceID ]
      •      
      •           Set Field [ invoicedetails_INVOICEITEM::Item; "Dep" ]
      •      
      •           Set Field [ invoicedetails_INVOICEITEM::Description; "Deposit for Club Fender" ]
      •      
      •           Set Field [ invoicedetails_INVOICEITEM::Price; INVOICE DETAILS::Deposit Amount/(INVOICE DETAILS::Tax_Percentage + 1) ]
      •      
      •           #Confirm payment
      •      
      •           Show Custom Dialog [ Title: "Settle Deposit"; Message: "Has the customer paid the deposit?"; Default Button: “Yes”, Commit: “Yes”; Button 2: “No”, Commit: “No” ]
      •      
      •           If [ Get (LastMessageChoice) = 1 ]
      •      
      •           Freeze Window
      •      
      •           

        Go to layout ["Schedule"(invoice details)]

             
      •      
      •           

        Set Field [ INVOICE DETAILS::status; "Yes" ]

             
      •      
      •           Go to Layout [ “Invoice” (INVOICE DETAILS) ]
      •      
      •           Set Field [ INVOICE DETAILS::Comments Invoice; "Received with thanks the sum of £" & INVOICE DETAILS::Deposit Amount ]
      •      
      •           Go to Layout [ “Schedule” (INVOICE DETAILS) ]
      •      
      •           Set Field [ INVOICE DETAILS::Schedule Base; "Deposit Paid" ]
      •      
      •           Refresh Window
      •      
      •           Commit Records/Requests [ Skip data entry validation; No dialog ]
      •      
      •           Go to Related Record [ From table: “invoicedetails_INVOICEITEM”; Using layout: “Invoice Print” (INVOICEITEMS) ] [ Show only related records ]
      •      
      •           Print Setup [ Orientation: Portrait; Paper size: 8.26" x 11.69" ] [ Restore; No dialog ]
      •      
      •           Print [ Current record; All Pages; Orientation: Portrait; Paper size: 8.26" x 11.69" ] [ Restore: Brother HL-3070CW series; No dialog ]
      •      
      •           Perform Find [ Specified Find Requests: Find Records; Criteria: INVOICE DETAILS::ID_Invoice_pk: “$OriginalInvoiceID” ] [ Restore ]
      •      
      •           Set Field [ INVOICE DETAILS::Deposit Link; $OriginalInvoiceID ]
      •      
      •           Set Field [ INVOICE DETAILS::Deposit Link; $InvoiceID ]
      •      
      •           Show Custom Dialog [ Title: "Select Customer"; Message: "Please add a new payment for this customer"; Default Button: “OK”, Commit: “Yes” ]
      •      
      •           Go to Layout [ “Payment List” (PYMNT) ]
      •      
      •           End If
      •      
      •           If [ Get (LastMessageChoice) = 2 ]
      •      
      •           Freeze Window
      •      
      •           

        Go to layout ["Schedule"(invoice details)]

             
      •      
      •           

        Set Field [ INVOICE DETAILS::status; "No" ]

             
      •      
      •           Go to Layout [ “Invoice” (INVOICE DETAILS) ]
      •      
      •           Set Field [ INVOICE DETAILS::Comments Invoice; "We shall commence manufacture on receipt of this deposit." ]
      •      
      •           Commit Records/Requests [ Skip data entry validation; No dialog ]
      •      
      •           Go to Related Record [ From table: “invoicedetails_INVOICEITEM”; Using layout: “Invoice Print” (INVOICEITEMS) ] [ Show only related records ]
      •      
      •           Print Setup [ Orientation: Portrait; Paper size: 8.26" x 11.69" ] [ Restore; No dialog ]
      •      
      •           Print [ Current record; All Pages; Orientation: Portrait; Paper size: 8.26" x 11.69" ] [ Restore: Brother HL-3070CW series; No dialog ]
      •      
      •           If [ Get (LastError) = 0 ]
      •      
      •           #Set Print TimeStamp
      •      
      •           Enter Browse Mode
      •      
      •           Go to Layout [ “Invoice” (INVOICE DETAILS) ]
      •      
      •           Set Field [ INVOICE DETAILS::TimeStamp_Printed Invoice; Get (CurrentTimeStamp) ]
      •      
      •           End If
      •      
      •           Go to Layout [ “Order” (INVOICE DETAILS) ]
      •      
      •           Show Custom Dialog [ Title: "Reminder!!"; Message: "Don't forget to chase the customer for the deposit!"; Default Button: “OK”, Commit: “Yes” ]
      •      
      •           Perform Find [ Specified Find Requests: Find Records; Criteria: INVOICE DETAILS::ID_Invoice_pk: “$OriginalInvoiceID” ] [ Restore ]
      •      
      •           Set Field [ INVOICE DETAILS::Deposit Link; $OriginalInvoiceID ]
      •      
      •           Set Field [ INVOICE DETAILS::Deposit Link; $InvoiceID ]
      •      
      •           Go to Layout [ “Schedule” (INVOICE DETAILS) ]
      •      
      •           Set Field [ INVOICE DETAILS::Schedule Base; "Awaiting Deposit" ]
      •      
      •           Go to Layout [ “Order” (INVOICE DETAILS) ]
      •      
      •           End If
      •      
      •           End If

        • 1. Re: Problem set field in print script
          JimMac

               Not enough info for a very complicated script.

               But a typical reason is....

               !) There are no records found on the related table.

               2) The field doesnt exist on the layouts you reference.

               Jim...

          • 2. Re: Problem set field in print script
            philmodjunk

                 2) does not apply to set field. Set field can modify the content of a field even if the field is not present on that layout. What matters is the table occurrence context (the data in parenthesis) in the go to layout step.

                 How doesn't it work? Is the status field formatted with radio buttons or check boxes? If so, have you checked the contents of this field in a copy of the field that is formatted as an edit box?

                 Does this script step work for you?

                 Set Field [ INVOICE DETAILS::Comments Invoice; "Received with thanks the sum of £" & INVOICE DETAILS::Deposit Amount ]

                 It appears after the steps shown in red and sets a field in the same record of the same table.

            • 3. Re: Problem set field in print script
              JimMac

                   Better said, Phil.

                   2) the Related Field doesnt exits on the Layout in context.

                   Jim...,

              • 4. Re: Problem set field in print script
                philmodjunk

                     Still does not apply. It makes no difference whether the field exists on the layout or not. What matters is the relationship, the table occurrence context and the value of any matchfields defined in that relationship in the current record.

                     Which is neither here nor there in the current script as the referenced field is not from a related table. I wonder if the script is on the correct record at the time the step executes...

                • 5. Re: Problem set field in print script

                       Hi Phil,

                       Now you come to mention it, that script doesnt work either! I thought as the script applies to the INVOICEDETAILS layout, then I could set fields on it?

                       The fields in question, that I want to put the data in, are already edit boxes. The two faulty scripts (including the one you mentioned above) are designed to add a text line on the invoice and accompagnying letter...

                       So should i be setting the field from the context of the invoice items table (INVOICEDETAILS_invoiceitems) or the customersINVOICEDETAILS table??

                        

                  • 6. Re: Problem set field in print script
                    philmodjunk

                         I don't think it's the layout, that's the problem. I suspect that your script is modifying the field, but in the wrong record.

                         If you have FileMaker Advanced, use the script debugger to step through the script to see what record you are on when these steps execute.

                         If you do not have advanced, insert some show custom dialog steps to pause the script just before and just after the set field steps so you can check and see what record is the current record at the moment the script step is performed.