Action button in outline, can it compose document and fill in values in field?

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?

@If(

@Contains(@DbColumn( “” : “NoCache” ; “” : “” ; “Creator Profile” ; 3 );@Name([Abbreviate];@UserName));

@Command([Compose];“Sales”);@Prompt([Ok];“Warning !!!”;“You are not allowed to create new Sale document.”));

FieldA:=FieldA;

FieldA:=“Report”;

Subject: Action button in outline, can it compose document and fill in values in field?

it would be easier if you used a lotus script agentthe outline would call the agent when clicked

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: RE: Action button in outline, can it compose document and fill in values in field?

you really need to learn LotusScriptand you will need to learn Java in order to survive in the Lotus Notes world

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?

still,it only compose the form,appreciates if you can guide me what is wrong with my formula here :slight_smile:

@Command([Compose];“Sales”);

@UpdateFormulaContext ;

@SetField(“FieldA”;“Report”)

Subject: Action button in outline, can it compose document and fill in values in field?

Not clear from your question what the nature of FieldA is. If it is an editable field in the UI, look at these commands:

@Command( [EditGotoField] ; “FieldA”)

@Command( [EditInsertText] ; “Report” )

Subject: RE: Action button in outline, can it compose document and fill in values in field?

it works, tqvm, fieldA is an editable text field, once entered, i want it to trigger relevant subform in the form. tq.

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 )

Subject: tqvm Michelle (eom)