Errors in duplicating a record

When I use a procedure to duplicate a record, some of the fields in the new record are left empty. Here are the details.

A form has 16 text editor objects. A button on the form allows the use to duplicate the record. The button does a farcall of the following procedure:

Alertsheet "Do you want to duplicate record "+«Case #»+
"?","Buttons","Yes,No"
If info("dialogtrigger")="No"
    rtn
endif
«Duplicate?»="Y"
duplicaterecord
ID=aggregate({ID},"max",{},"",true())+1  //Assigns the new record a unique ID
showvariables fgdummy
rtn

Of the 16 fields, 11 are duplicated but 5 are empty. I cannot find any explanation for the difference.

Update: if I replace the duplicate record line above with copy record paste record, the problem is solved. All fields are duplicated.

This is certainly a puzzling report.

The duplicaterecord statement is actually a custom statement, so running it actually runs this code:

let r = exportline()
insertbelow
importline r

The copyrecord statement is implemented in Objective-C, but that code actually calls the same exportline( code used above.

OperandToken * recordTextToken = [PanExpression evaluateFunction:[[ExportLineFunction alloc] init]];
NSString * recordText = [recordTextToken getStringValue];
[ScrapCalcStatement copyTextToPasteboard:recordText];

The pasterecord statement is also implemented in ObjC, but that ObjC code actually invokes an internal procedure.

[PanProcedure CompileAndRun:@"local nstate nstate=info({noshow}) noshow insertrecord importline clipboard() if nstate=false() showother {},4 endnoshow endif nop"];

So, duplicaterecord and copyrecord/pasterecord actually do the exact same thing! I guess the one difference is one uses insertbelow and the other uses insertrecord. But that shouldn’t make any difference.

Is there anything unusual about the 5 empty fields? Are they text, numbers, binary data?

I do not see anything unusual about the fields; they are all text fields.

Well if it’s practical to send the database to me, I’ll be happy to check it out.

Oh, one other question - are the 5 missing fields on the end? or distributed in between the other fields? And did you try this on different records?