10 Replies Latest reply on Aug 15, 2013 2:44 PM by philmodjunk

    related record check

      Title

      related record check

      Post

           I have a simple problem but experiencing brain freeze.

           I have a table called invoice details. I have another occurance of this table called Deposit link. The point is, when an invoice details record is created, I want another "duplicate' invoice details record to be created - one is for a deposit amount, the other for the main invoice. 
            I want to create a script that will check whether or not the balance in the deposit link record is 0. The field is called balance_due

           From invoice details, how should I write the script? Do I use a GTRR or a set variable? The two occurances are linked using a field called 'link'. They both contain the same serial number on creation of deposit invoice...

           Thanks

            

        • 1. Re: related record check
          philmodjunk

               A relationship such as:

               Invoice Details::PrimaryKey = Deposit link::ForeignKey

               would allow a Invoice Details record to link to one and only one record via the relationship to the Deposit Link table occurrence.

               PrimaryKey would be defined as an auto-entered serial number. ForeignKey would be a simple number field.

               But it doesn't sound like this is the relationship that you have set up here.

          • 2. Re: related record check

                 Hi Phil 
                 Actually this is how i Have it set up (sort of). On creation of the first invoice, from invoice details, a pk field is autofilled with serial number. When a deposit is created, this original 'pk' is copied to the link field of the same table and then held as a variable, then copied to new ivoice details record. These two fields are linked via a relationship - does that make any sense? So any two records can be linked by this relationship..

            • 3. Re: related record check
              philmodjunk

                   Yes, but it's NOT what I am recommending.

                   Instead of:

                   InvoiceDetails::Link = DepositLink::Link

                   use:

                   InvoiceDetails::auto-enteredSerialNumberField = DepositLink::Link

                   See the difference? Don't use the same field for a match on both sides of the relationship as that then matches to two records, both the deposit AND the originating record.

                   And don't use any script to copy values around in the current record for this. If "allow creation..." is enabled for DepositLink in this relationship, you can generate the needed related record with a single script step from the context of the original invoice details record:

                   Set Field [DepositLink::Link ; InvoiceDetails::auto-enteredSerialNumberField ]

                   And the specific field doesn't really matter here. Set any field from DepositLink to a value in this context and a new, related record will be automatically created and the Link field in the new record will automatically receive a matching value from the serial number field of the original record.

              • 4. Re: related record check

                     Ah yes - I do see now - thanks.  I shall have ago later and report back if stuck...

                     Once this relationship is fixed, then how do I go about my original question? Just by simply referring to the field (balance due) in the deposit link occurance?

                      

                • 5. Re: related record check
                  philmodjunk

                       Yes. That's the whole point to this relationship change, to get a relationship that only matches to the linked deposit record.

                  • 6. Re: related record check

                         Forgot to mention- not every invoice details record is required to create a deposit invoice. The invoice details record contains data for quote, order or invoice depending on the progress of the 'job'. So it is only after an invoice details record has been created and upgraded from quote to invoice that the user has the option to then create a deposit invoice 

                    • 7. Re: related record check
                      philmodjunk

                           That should not be an issue. If you need the linked deposit record for a given invoice details record, create it. If you don't need it, don't.

                      • 8. Re: related record check

                             I tried to alter as you suggested but things stopped working! Below is my working script to create a deposit invoice from invoice details table/layout.

                             What I want to add to this (as another script) is to check whether the deposit has been paid - this would be by tesint the invoicedetails::balance due field being 0..

                             It is a rather long script so have highlighted the relevent parts..

                              

                               
                        •           Allow User Abort [ Off ]
                        •      
                        •           Set Error Capture [ On ]
                        •      
                        •           If [ INVOICE DETAILS::fk_Order = "N/A" ]
                        •      
                        •           Show Custom Dialog [ Title: "Message"; Message: "This order does not require a confirmation or deposit. Please convert to invoice."; Default Button: “OK”, Commit: “Yes” ]
                        •      
                        •           Exit Script [ ]
                        •      
                        •           End If
                        •      
                        •           If [ INVOICE DETAILS::Deposit Created = "Yes" ]
                        •      
                        •           Show Custom Dialog [ Title: "ERROR"; Message: "You have already raised a deposit invoice for " & INVOICE DETAILS::Billing_Address to & ". To reprint/email this deposit invoice, go to the actual invoice screen and print from there."; Default Button: “OK”, Commit: “Yes” ]
                        •      
                        •           Exit Script [ ]
                        •      
                        •           End If
                        •      
                        •           If [ INVOICE DETAILS::Deposit Created = "No Deposit" ]
                        •      
                        •           Show Custom Dialog [ Title: "ERROR"; Message: INVOICE DETAILS::Billing_Address to & " is not paying a deposit. If they are now paying a deposit, click 'deposit'. "; Default Button: “OK/Cancel”, Commit: “Yes”; Button 2: “Deposit”, Commit: “No” ]
                        •      
                        •           If [ Get(LastMessageChoice)=1 ]
                        •      
                        •           Exit Script [ ]
                        •      
                        •           End If
                        •      
                        •           If [ Get (LastMessageChoice) = 2 ]
                        •      
                        •           Show Custom Dialog [ Title: "Deposit"; Message: "Please enter the amount the client is to pay."; Default Button: “OK”, Commit: “Yes”; Button 2: “Cancel”, Commit: “No”; Input #1: INVOICE DETAILS::Deposit Amount, "How Much (£)" ]
                        •      
                        •           #Set up variables
                        •      
                        •           If [ Get (LastMessageChoice) = 2 ]
                        •      
                        •           Exit Script [ ]
                        •      
                        •           End If
                        •      
                        •           Freeze Window
                        •      
                        •           Set Field [ INVOICE DETAILS::Deposit Link; INVOICE DETAILS::ID_Invoice_pk ]
                        •      
                        •           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 Variable [ $ShipAddTo; Value:INVOICE DETAILS::Shipping_address to ]
                        •      
                        •           Set Variable [ $ShippingTo; Value:INVOICE DETAILS::Shipping_to ]
                        •      
                        •           Set Variable [ $Ship1; Value:INVOICE DETAILS::Shipping_Address 1 ]
                        •      
                        •           Set Variable [ $Ship2; Value:INVOICE DETAILS::Shipping_Address 2 ]
                        •      
                        •           Set Variable [ $Ship3; Value:INVOICE DETAILS::Shipping_Address 3 ]
                        •      
                        •           Set Variable [ $Ship4; Value:INVOICE DETAILS::Shipping_Address 4 ]
                        •      
                        •           Set Variable [ $Ship5; Value:INVOICE DETAILS::Shipping_Address 5 ]
                        •      
                        •           Set Variable [ $ShipCountry; Value:INVOICE DETAILS::Shipping_Country ]
                        •      
                        •           Set Variable [ $ShipPhone; Value:INVOICE DETAILS::Shipping_Phone ]
                        •      
                        •           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
                        •      
                        •           Set Variable [ $InvoiceID; Value:INVOICE DETAILS::ID_Invoice_pk ]
                        •      
                        •           Set Field [ INVOICE DETAILS::Deposit Invoice; "Yes" ]
                        •      
                        •           #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; $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" ]
                        •      
                        •           Set Field [ INVOICE DETAILS::Shipping_Address 1; $Ship1 ]
                        •      
                        •           Set Field [ INVOICE DETAILS::Shipping_Address 2; $Ship2 ]
                        •      
                        •           Set Field [ INVOICE DETAILS::Shipping_Address 3; $Ship3 ]
                        •      
                        •           Set Field [ INVOICE DETAILS::Shipping_Address 4; $Ship4 ]
                        •      
                        •           Set Field [ INVOICE DETAILS::Shipping_Address 5; $Ship5 ]
                        •      
                        •           Set Field [ INVOICE DETAILS::Shipping_address to; $ShipAddTo ]
                        •      
                        •           Set Field [ INVOICE DETAILS::Shipping_to; $ShippingTo ]
                        •      
                        •           Set Field [ INVOICE DETAILS::Shipping_Country; $ShipCountry ]
                        •      
                        •           Set Field [ INVOICE DETAILS::Shipping_Phone; $ShipPhone ]
                        •      
                        •           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" & " " & $Order ]
                        •      
                        •           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” ]
                        •      
                        •           #Paid
                        •      
                        •           If [ Get (LastMessageChoice) = 1 ]
                        •      
                        •           Go to Layout [ “Invoice” (INVOICE DETAILS) ]
                        •      
                        •           Set Field [ INVOICE DETAILS::Comments Invoice Deposit; "Received with thanks, the sum of £" & INVOICE DETAILS::Deposit Amount ]
                        •      
                        •           Commit Records/Requests [ Skip data entry validation; No dialog ]
                        •      
                        •           Perform Find [ Specified Find Requests: Find Records; Criteria: INVOICE DETAILS::ID_Invoice_pk: “$OriginalInvoiceID” ] [ Restore ]
                        •      
                        •           Set Field [ INVOICE DETAILS::ID_Invoice_pk; $OriginalInvoiceID ]
                        •      
                        •           Set Field [ INVOICE DETAILS::Schedule Base; "In Manufacture" ]
                        •      
                        •           Show Custom Dialog [ Title: "Enter Payment"; Message: "Please add new payment for " & invoicedetails_CUSTOMERS__billing::Address To & "."; Default Button: “OK”, Commit: “Yes” ]
                        •      
                        •           Go to Layout [ “Payment List” (PYMNT) ]
                        •      
                        •           End If
                        •      
                        •           #Not Paid
                        •      
                        •           If [ Get (LastMessageChoice) = 2 ]
                        •      
                        •           Go to Layout [ “Invoice” (INVOICE DETAILS) ]
                        •      
                        •           Set Field [ INVOICE DETAILS::Comments Invoice Deposit; "We shall commence manufacture on receipt of this deposit." ]
                        •      
                        •           Set Field [ INVOICE DETAILS::Schedule Base; "Awaiting Deposit" ]
                        •      
                        •           Commit Records/Requests [ Skip data entry validation; No dialog ]
                        •      
                        •           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::ID_Invoice_pk; $OriginalInvoiceID ]
                        •      
                        •           Go to Layout [ “Order” (INVOICE DETAILS) ]
                        •      
                        •           End If
                        •      
                        •           End If
                        •      
                        •           If [ Get (LastMessageChoice) = 2 ]
                        •      
                        •           Set Field [ INVOICE DETAILS::Schedule Base; "In Manufacture" ]
                        •      
                        •           Set Field [ INVOICE DETAILS::Deposit Created; "No Deposit" ]
                        •      
                        •           End If
                        •      
                        •           Exit Script [ ]
                        •      
                        •           End If
                        •      
                        •           #Full Script
                        •      
                        •           Show Custom Dialog [ Title: "Deposit"; Message: "Is this client paying a deposit?"; Default Button: “Yes”, Commit: “Yes”; Button 2: “No”, Commit: “No” ]
                        •      
                        •           If [ Get(LastMessageChoice)=1 ]
                        •      
                        •           Show Custom Dialog [ Title: "Deposit"; Message: "Please enter the amount the client is to pay."; Default Button: “OK”, Commit: “Yes”; Button 2: “Cancel”, Commit: “No”; Input #1: INVOICE DETAILS::Deposit Amount, "How Much (£)" ]
                        •      
                        •           #Set up variables
                        •      
                        •           Freeze Window
                        •      
                        •           Set Field [ INVOICE DETAILS::Deposit Link; INVOICE DETAILS::ID_Invoice_pk ]
                        •      
                        •           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 Variable [ $ShipAddTo; Value:INVOICE DETAILS::Shipping_address to ]
                        •      
                        •           Set Variable [ $ShippingTo; Value:INVOICE DETAILS::Shipping_to ]
                        •      
                        •           Set Variable [ $Ship1; Value:INVOICE DETAILS::Shipping_Address 1 ]
                        •      
                        •           Set Variable [ $Ship2; Value:INVOICE DETAILS::Shipping_Address 2 ]
                        •      
                        •           Set Variable [ $Ship3; Value:INVOICE DETAILS::Shipping_Address 3 ]
                        •      
                        •           Set Variable [ $Ship4; Value:INVOICE DETAILS::Shipping_Address 4 ]
                        •      
                        •           Set Variable [ $Ship5; Value:INVOICE DETAILS::Shipping_Address 5 ]
                        •      
                        •           Set Variable [ $ShipCountry; Value:INVOICE DETAILS::Shipping_Country ]
                        •      
                        •           Set Variable [ $ShipPhone; Value:INVOICE DETAILS::Shipping_Phone ]
                        •      
                        •           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
                        •      
                        •           Set Variable [ $InvoiceID; Value:INVOICE DETAILS::ID_Invoice_pk ]
                        •      
                        •           Set Field [ INVOICE DETAILS::Deposit Invoice; "Yes" ]
                        •      
                        •           #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; $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" ]
                        •      
                        •           Set Field [ INVOICE DETAILS::Shipping_Address 1; $Ship1 ]
                        •      
                        •           Set Field [ INVOICE DETAILS::Shipping_Address 2; $Ship2 ]
                        •      
                        •           Set Field [ INVOICE DETAILS::Shipping_Address 3; $Ship3 ]
                        •      
                        •           Set Field [ INVOICE DETAILS::Shipping_Address 4; $Ship4 ]
                        •      
                        •           Set Field [ INVOICE DETAILS::Shipping_Address 5; $Ship5 ]
                        •      
                        •           Set Field [ INVOICE DETAILS::Shipping_address to; $ShipAddTo ]
                        •      
                        •           Set Field [ INVOICE DETAILS::Shipping_to; $ShippingTo ]
                        •      
                        •           Set Field [ INVOICE DETAILS::Shipping_Country; $ShipCountry ]
                        •      
                        •           Set Field [ INVOICE DETAILS::Shipping_Phone; $ShipPhone ]
                        •      
                        •           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" & " " & $Order ]
                        •      
                        •           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” ]
                        •      
                        •           #Paid
                        •      
                        •           If [ Get (LastMessageChoice) = 1 ]
                        •      
                        •           Go to Layout [ “Invoice” (INVOICE DETAILS) ]
                        •      
                        •           Set Field [ INVOICE DETAILS::Comments Invoice Deposit; "Received with thanks, the sum of £" & INVOICE DETAILS::Deposit Amount ]
                        •      
                        •           Commit Records/Requests [ Skip data entry validation; No dialog ]
                        •      
                        •           Perform Find [ Specified Find Requests: Find Records; Criteria: INVOICE DETAILS::ID_Invoice_pk: “$OriginalInvoiceID” ] [ Restore ]
                        •      
                        •           Set Field [ INVOICE DETAILS::ID_Invoice_pk; $OriginalInvoiceID ]
                        •      
                        •           Set Field [ INVOICE DETAILS::Schedule Base; "In Manufacture" ]
                        •      
                        •           Show Custom Dialog [ Title: "Enter Payment"; Message: "Please add new payment for " & invoicedetails_CUSTOMERS__billing::Address To & "."; Default Button: “OK”, Commit: “Yes” ]
                        •      
                        •           Go to Layout [ “Payment List” (PYMNT) ]
                        •      
                        •           End If
                        •      
                        •           #Not Paid
                        •      
                        •           If [ Get (LastMessageChoice) = 2 ]
                        •      
                        •           Go to Layout [ “Invoice” (INVOICE DETAILS) ]
                        •      
                        •           Set Field [ INVOICE DETAILS::Comments Invoice Deposit; "We shall commence manufacture on receipt of this deposit." ]
                        •      
                        •           Set Field [ INVOICE DETAILS::Schedule Base; "Awaiting Deposit" ]
                        •      
                        •           Commit Records/Requests [ Skip data entry validation; No dialog ]
                        •      
                        •           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::ID_Invoice_pk; $OriginalInvoiceID ]
                        •      
                        •           Go to Layout [ “Order” (INVOICE DETAILS) ]
                        •      
                        •           End If
                        •      
                        •           End If
                        •      
                        •           If [ Get (LastMessageChoice) = 2 ]
                        •      
                        •           Set Field [ INVOICE DETAILS::Schedule Base; "In Manufacture" ]
                        •      
                        •           Set Field [ INVOICE DETAILS::Deposit Created; "No Deposit" ]
                        •      
                        •           End If
                        • 9. Re: related record check

                               Have sorted it in a round about way - but it works...Thanks

                          • 10. Re: related record check
                            philmodjunk

                                 I am guessing that this is the relationship:

                                 Invoice Details::ID_Invoice_pk = DepositLink::Link

                                 If so, do it this way:

                                   
                            •           Set Field [ Deposit Link::Link ; INVOICE DETAILS::ID_Invoice_pk ]--> I am assuming that ID_Invoice_pk is an auto-entered serial number.

                                 That's it. Just one line in place of all that red code--provided "allow creation..." is enabled as I specified earlier.

                                 To get all the other data that you are copying over via variables, you have two options, neither of which require specific script steps to accomplish:

                                 1) If you use a layout just for deposits, base that layout on the DepositLink table occurrence and add the fields that you need from the related Invoice Details table occurrence. Then there is no need to copy over the data at all.

                                 2) Open up Invoice Details and for each of these fields, specify a looked up value auto-enter field option. Select DepositLink in the Starting With Table: drop down and then select Invoice Details in the Lookup from related table drop down. Then select the field in the list of fields that appears below the drop down.

                                 When your script executes the Set FIeld step, a new record will be created if a depositLink record does not already exist. Then the Looked up value field options automatically copy over data from the specified fields in the original record.