1
votes

Basically what I want to do is create a form whilst within another form and pass values from the earlier form to the second. Complicated I know but here is what I got.

@Do(@Command([Compose];"LPK"); @SetField("PR_Make"; PR_Make))

The fields in both forms have the same name and this code is called when first document is attempted to be saved. I think instead of editing the field on the second form it just saves a field as itself instead. Any help appreciated.

2

2 Answers

2
votes

The best and common way is to enable form property "Formulas inherit values from selected document" in second form "LPK".

enter image description here

Add a default value formula to second form's fields you want to inherit and put just the name of field itself in. For your example default value formula it would be

PR_Make

Make sure you save document first and then create the new document.

0
votes

Knut Hermann's answwer is the 'standard' way of achieving such things but there are other methods- eg you can use environment variables ..

Something like:

@Environment("PR_Make") := PR_Make;
@Command([Compose];"LPK"); 

Then set the default value for PR_Make in your new form as ..

@Environment("PR_Make")

FYI Environment variables are written to the user's Notes.ini file and so remain even after Notes has been closed and re-opened. @Environemt doens't work too well with Web applications as it uses the server's notes.ini.

An alternative would be to use profile documents:

@SetProfileField( "PRDefaults"; "PR_Make" ; PR_Make;@Username);
@Command([Compose];"LPK"); 

.. in the default field for PR_Make on new form :

@GetProfileField( "PRDefaults"; "PR_Make"; @Username);

Profile documents are stored as a kind of hidden document in the Notes database and persist with the database. The last parameter sets a further subdivision by username so each user gets their own profile doc - a bit like a personal profile for "PRDefaults". You can miss this last parameter @Username out, to have one profile doc per database but there's a risk of two people trying to use it at the same time and clashing.

Profile docs also work with web applications.