?
Solved

Change Form from Action Button

Posted on 2000-02-07
7
Medium Priority
?
444 Views
Last Modified: 2013-12-18
Is there a way to decide which form to use based upon which action button a user clicks? I've set up Roles that allow editing of different fields for a document & a corresponding Form for each scenario. I've linked those roles to a view Form Formula, as follows:

@If(@IsMember("[EditEquip]";@UserRoles);"Equipment";"Log Usage"));

This works fine, but I'd like to present these users with an option to use either form, so I modified the formula, as follows:

@If(@IsMember("[EditEquip]";@UserRoles);
        @If(@Prompt([OKCANCELLIST];"Select Function";"What do you wish to do?";"Edit Equipment";"Edit Equipment":"Log Usage") = "Edit Equipment";"Equipment";"Log Usage");"Log Usage")

This works also, but I'd like to present authorized users with 2 different action Buttons, Edit Equipment & Log Usage, & bring up the document with the appropriate form based upon which they clicked. Any ideas?


0
Comment
Question by:Raybone
7 Comments
 
LVL 2

Expert Comment

by:Paebdb
ID: 2497323
If your button is in a view, you basically just have to reset the Form field

FIELD form="Name";
<open doc here>

That should do it... sorry for the short answer, have to go :)
0
 

Author Comment

by:Raybone
ID: 2497539
This was the first (& Most obvious) thing I tried, but it presents a problem of timing: The Form Field isn't updated until AFTER the document is opened & saved. Therefore, the document opens with the wrong form.

Example:

1) Form = "FormA"
   Click Button which says:
     FIELD Form := "FormB";
     @Command([EditDocument];1)
   Document opens with FormA. After the document is saved, it opens with FormB next time.

2) Form = "FormB"
   Click Button which says:
     FIELD Form := "FormA";
     @Command([EditDocument];1)
   Document opens with FormB. After the document is saved, it opens with FormA next time.

I've tried saving it first, but I got save conflicts.
0
 
LVL 7

Expert Comment

by:Z_Beeblebrox
ID: 2497732
If your button is in a view, rather than a form, then you can avoid this problem. Otherwise, have your button save then close the document, then reopen it, using:

@Command([FileSave]);
@Command([FileCloseWindow]);
@Command([OpenDocument])

This should work (I hope) but if you are getting save conflicts then there is some other piece of code somewhere else that is causing problems. The easiest way to accomplish what you want to accomplish is to have a button on a view or navigator.

Zaphod.
0
Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

 

Accepted Solution

by:
shabala earned 300 total points
ID: 2498269
Try something like this from a View Action Button.

Choice := @Prompt([OKCANCELLIST]:[NoSort]; "Initiate"; "Please select one of the following:"; "Form";"Form A": "Form B");
@Command([ViewSwitchForm]; Choice)
0
 
LVL 1

Expert Comment

by:rfharris
ID: 2498531
I doubt that shabala's solution will work from View Action Button as the ViewSwitchForm cannot work against the yet unopened document.  Perhaps placing it in a Form Action Button instead (to be clicked after the user opens the form?)

Is the order of the sequence unmovable?  Have you considered having them open a "generic" document layout and then allowing them pick different ways to view the currently open document using computed subforms?

If you are flexible in the order of events ("open then pick" vs "pick then open") .. I'd suggest:
1) Create a keyword field at the top of a nearly blank form.  The keyword style can be anything you like -- but limited to single value.  The field's properties should be set to refresh the form on change.
2) Create subforms to contain each of the "customized form layouts" appropriate for each role.  Also create a generic/default subform that will be displayed immediately on the initial open of the form (before the user selects a new look from your keyword field).
3) Use the computed subform feature on your main form to select (load and display) the appropriate custom subform when the user changes the keyword field.

One of the beauties of this approach is that you can combine different keyword fields based on their roles (think "hide/when") with some very sophisticated tailoring in the computed subform formula.

The drawback, however, is the order of events.  If the users can handle the order "open then pick" then this approach may work for you.
0
 

Expert Comment

by:shabala
ID: 2501690
How about using script such as the following:

Dim s As New Notessession
Dim db As Notesdatabase
Set db = s.Currentdatabase
Dim docol As Notesdocumentcollection
Set docol = db.Unprocesseddocuments
Dim doc As Notesdocument
Set doc = docol.Getfirstdocument()
doc.Form = "<The new form>"
Dim w As New NotesUIWorkspace
Call w.Editdocument("1", doc)
0
 

Author Comment

by:Raybone
ID: 2501851
I found a simple answer myself using environment variables, as follows:

Button1 - Log Usage:
 @Environment("UseForm";"Log Usage");
 @Command([EditDocument];1)

Button2 - Edit Equipment:
 @Environment("UseForm";"Equipment");
 @Command([EditDocument];1)

View Form-Selection Formula:
@If(@IsMember("[EditEquip]";@UserRoles);
        @Environment ("UseForm");"Log Usage")
0

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

You’ve got a lotus Domino web server, and you have been told that “leverage browser caching” is a must do. This means that we have to tell the browser everywhere in the web to use cache. In other words, we set (and send) an expiration date in the HT…
Problem "Can you help me recover my changes?  I double-clicked the attachment, made changes, and then hit Save before closing it.  But when I try to re-open it, my changes are missing!"    Solution This solution opens the Outlook Secure Temp Fold…
The Relationships Diagram is a good way to get an overall view of what a database is keeping track of. It is also where relationships are defined. A relationship specifies how two tables connect to each other. As you build tables in Microsoft Ac…
In this video I will demonstrate how to set up Nine, which I now consider the best alternative email app to Touchdown.
Suggested Courses

601 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question