The following formula works in an outline, whereby upon clicking the outline, it will first check whether do I have authorization to create document, than it will compose a new document using the form Sales. however, I want it also to fill in the values of fieldA with value of “Report”, currently it does not do it, is there any problem with my form?
Subject: RE: Action button in outline, can it compose document and fill in values in field?
lotus script not my expertise, I will try to avoid it if possible. really appreciate if you don’t mind giving me some tips how to write it, if it is easier to write it via script agent.
Subject: Action button in outline, can it compose document and fill in values in field?
Formulas execute within the context of where they are called. With your formula above, it will be trying to set FieldA on the page or form where your outline is embedded.
There is an @formula - @UpdateFormulaContext which will switch the context of your formula to the new document. Put this after @Compose.
There is also no longer any need with Notes 6 or greater to ‘initialise’ the field value with the line FieldA := FieldA (unless this formula also needs to work in R5).
Subject: RE: Action button in outline, can it compose document and fill in values in field?
Subforms only load when your form loads. You can’t compose the form, set a field then load a subform.
LotusScript really is the only way to do this. You need to create a document, set fieldA, then open your form in the UI
dim ws as new NotesUIWorkspace
dim session as New NotesSession
dim db as NotesDatabase
dim doc as NotesDocument
set db = session.CurrentDatabase
set doc = new NotesDocument( db )
doc.FieldA = “myValue”
doc.Form = “myForm”
call ws.EditDocument( True, doc ) ’ check the help, I’m writing this from memory
Note: this will create a main document, even if your form is a response form. If you are needing to create a response document you will need to get the currently selected document (check out NotesUIWorkspace.UnprocessedDocuments and NotesDocumentCollection.GetFirstDocument in the designer help) and make the new document a response to the selected one ( NotesDocument.MakeResponse )