Formula behaving differently between R5 and R6

I have this formula in a form action button:

@If(@Command([FileSave]); “”; @Return(“”));

@Command([EditDocument]; “0”);

ENVIRONMENT currentMtr:=@Text(mtrNumber)+“/”+@Trim(mtrYear)+mtrCourt;

ENVIRONMENT currentMtrUNID:=@Text(@DocumentUniqueID);

@PostedCommand([Compose]; “”; “frmParty”)

In a Notes 5 client, this button works perfectly every time.

The current document is saved, the environment variables are set to the correct values, and a new document is composed.

In an Notes 6 client, it behaves differently.

The current document is saved and the new document is composed, but the environment variables are incorrectly set.

The $currentMtr variable is set to “/”, as if the mtrNumber, mtrYear, and mtrCourt fields were all blank

The $currentMtrUNID variable is set to “00000000000000000000000000000000” (32 x “0”), as if the current document was new.

Also, I have tried using @SetEnvironment instead of ENVIRONMENT, with exactly the same result.

The only explanation I can see is that, in Notes 6, the ENVIRONMENT lines must be running after the [Compose] command.

Does anyone know if the execution order of formula statements has been changed in Notes 6, and if there is anything I can do to fix this?