What cause portal record to disappear after saving or going to another record?

I'm trying to duplicate records and its portal records ( a sales invoice), I was able to duplicate all the data on a record, even on the portal. but when I save the record, all the data in the portal is gone! and whenever I go to another record, the data is gone also.

I can see the portal records but its gone the minute I save or go to another record.

I think when I duplicate the record, it does not save it to the line item?

What could be the cause of this?

This is the script i use by Philmodjunk

Freeze Window

Set variable [$RecordNumber ; Value: Get ( RecordNumber ) ]

Duplicate Record

Set Variable [$ID ; SALES::pk_ID]

Go To Record/Request/Page [$RecordNumber]

If [ Not IsEmpty ( LineItems::fk_ID ) /* there are line items to duplicate */]

Go To Related Record [Show only related records; From table: lineItems; Using layout: "lineItems" (lineItems)] Go To Record/Request/Page [first] Loop Duplicate Record Set Field [ LineItems::fk_BOMID ; $ID] Omit Record Go To Record/Request/Page [first] Omit Record Exit loop If [ get ( FoundCount ) = 0 ] End Loop Go To Layout [original layout] Go To Record/Request/Page [Last]End IF

Your serial number settings for the Invoice PK are set up to assign the value "on commit", The script I wrote is for a serial number assigned "on creation"--the default option for an auto-entered serial number. Either change this setting back to "on creation" or add a commit records step immediately after the duplicate records step.

You also should turn off the dialog option for the first go to record step so that you don't have to Ok that move every time.

Attachments

Your serial number settings for the Invoice PK are set up to assign the value "on commit", The script I wrote is for a serial number assigned "on creation"--the default option for an auto-entered serial number. Either change this setting back to "on creation" or add a commit records step immediately after the duplicate records step.

You also should turn off the dialog option for the first go to record step so that you don't have to Ok that move every time.

Because the serial is not assigned until commit, the duplicated record initially has the same ID as the record being duplicated. The variable then gets the wrong ID and that wrong value is then assigned to the duplicate line items. If you have FileMaker Advanced, you can use the debugger and data viewer to watch this happen.