January 5, 201115 yr I've created the script down below to input record in a table called InvoiceOrder using a return-separated list of code. The script is looping through the entire list and is creating required records in the InvoiceOrder table. However, there is always a none required empty record which gets added at the end of the table. I do not know why, could someone tell what I've done wrong with this script? Best regards! Daniel Go to Related Record [From table: “CustomerOrder”;Using layout <Current Layout>] Set Variable [ListArray1; Value:Substitute ( TrimAll ( Order1 & " "; 0 ; 0 ) ; " " ; ¶ )] Set variable [$InvoiceNo;Value:CustomerOrder::NoInvoice] Loop Loop Exit Loop If [ValueCount ($ListArray1) = 0] Set Field [invoiceOrder::OrderNo;GetValue ($ListArray1 ;1)] Set Field [invoiceOrder::IndexNo;1] Set Field [invoiceOrder::OrderStatus;”C”] Go to Layout [“InvoiceOrder” (InvoiceOrder) ] New Record/Request set Variable [$ListArray1;Value:Let(count=ValueCount($ListArray1);RightValues($ListArray1; count-1))] End Loop Go to Record/Request/Page[Next; Exit after Last] End Loop
January 5, 201115 yr You need to create a record first, then set its fields. BTW, I don't see why you need two loops here. If you are creating child records, you should first handle a situation where child records already exist - otherwise you will have duplicates. After that, you can: Set Variable [ $list; Value: ... ] Set Variable [ $invoiceNo; Value:CustomerOrder::NoInvoice ] # Go to Layout [ “InvoiceOrder” (InvoiceOrder) ] Loop Set Variable [ $i; Value: $i + 1 ] Exit Loop If [ $i > ValueCount ( $list) ] New Record/Request Set Field [ InvoiceOrder::InvoiceNo; $invoiceNo ] Set Field [ InvoiceOrder::OrderNo; GetValue ( $list ; $i ) ] # SET MORE FIELDS HERE End Loop # Go to Layout [ original layout ]
Create an account or sign in to comment