Jump to content
Claris Engage 2025 - March 25-26 Austin Texas ×

This topic is 5072 days old. Please don't post here. Open a new topic instead.

Recommended Posts

Posted

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

Posted

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 ]

This topic is 5072 days old. Please don't post here. Open a new topic instead.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.