Change field value in view action - field will be used for hide-when formulas

My main form contains a hidden field ( text field )called: Test_Nr. It is computed and it’s default value is “”.

Also, the form contains one subform which have numerous fields because, in other words, the form contains 2 types of document: Doc A and Doc B. There are some “common” fields which Doc A and Doc B are having.

The are some fields on the subform ( which is contained by the main form ) that, together, create the DOC A, and some other fields that create DOC B.

I have two views. I want the first view to have an action for opening the form to get the Doc A and a view that has an action to open the form for Doc B.

My first view action code is :

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

@SetField(“Test_Nr”;“01”);

Those numerous fields that I want to appear in Doc A have at the hide-when formula:

@If(“Test_Nr”=“01”;@False;@True)

For the second view, the action code is :

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

@SetField(“Test_Nr”;“02”);

and the hide-when formula for fields that compose the doc A is:

@If(“Test_Nr”=“02”;@False;@True).

In other words, on clicking the 1st view action, I want to obtain DOC A. ( the fields that are not from DOC A, to be hidden ) and when clicking on 2nd view action to obtaion DOC B ( the fields that are not from DOC B, to be hidden ).

If I click the action on the 1st view: the Test_Nr value is “” if I click the action on the 2nd view the Test_Nr value is “”, also. So, the form is empty …

Please help me, this issue gives me some headache. Thanks

Subject: Change field value in view action - field will be used for hide-when formulas

First of all, you should use two different forms, if you really want to treat it as two different document types.Forms can not “contain 2 types of documents”, the form is one document type.

You might mean that the form can look two different ways, depending on the value of the hidden field. But don’t start mixing in “Doc A” and “Doc B”.

In order to do what you want (which will only work if the documents are created from those specific buttons in the views), you need to write the action button code as Lotusscript.

Create a NotesDocument in memory, set the value of the hidden field using the ReplaceItemValue() method, then open it to the user with the EditDocument() method of the NotesUIWorkspace class.

Subject: RE: Change field value in view action - field will be used for hide-when formulas

Thanks for your response! Yes, depending on the value of the hidden field, I want the form to look two different ways. How can I set the form’s name in lotusscript … smth like odoc.Form = “name”

Do i Should use Call ws.ComposeDocument( “”, “”, “fmMain” ) ? After the Call odoc.ReplaceItemValue(“Test_Nr”, “02”)

Could you give me the code in lotusscript ( in which I’m newbie ) for the action button?

I tried smth like this…:

             Dim session As New NotesSession

Dim ws As New NotesUIWorkspace

Dim db As New NotesDatabase("", "")

Dim scDoc As New NotesDocument(db)



scDoc.Form="fmMain"

Call scDoc.ReplaceItemValue("Test_Nr", "03")

Call ws.EditDocument(True, scDoc)

But i get the message: Database has not been opened yet

EDIT: this topic question is very similar to mine :

http://www-10.lotus.com/ldd/nd6forum.nsf/55c38d716d632d9b8525689b005ba1c0/aa3dc84c05bcef0f85256e29002ab246?OpenDocument

Please help me! I appreciate your time and your sharing informations! Phaul

LATER EDIT: I think I found the solution:

             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 )

Call doc.ReplaceItemValue("Test_Nr","01")

doc.Form = "fmMain"

Call ws.EditDocument( True, doc )

THank you, dear Karl! Have a nice day