Link to home
Start Free TrialLog in
Avatar of Ray Padilla
Ray PadillaFlag for United States of America

asked on

Action from a view (ND6.5 edit view option)

Hola Experts! Here it is I have a form with a button that opens a network drive then displays a map on a browser of the office locations, a small java application then "points" at the employees desk location on the map.....currently you have to open the form from the view in order to make this function, what I would like to do is have the user be able to click on the desk location on the view and have it run this formula:
mapPath := "file:\\server\\folder\\folder\\folder\\folder\\";
@If(@Trim(DeskLocation)="";@Do(@Prompt( [Ok];"Aborting";"The Desk Location Field is Blank.");@Return(""));"");
quad := @Text(@Left(DeskLocation;2));
mapfile := @If(quad = "11";"floor1w.html";quad = "12";"floor1w.html";quad = "13";"floor1e.html";quad = "14";"floor1e.html";quad = "21";"floor2w.html";quad = "22";"floor2w.html";quad = "23";"floor2e.html";quad = "24";"floor2e.html";quad = "31";"floor3w.html";quad = "32";"floor3w.html";quad = "33";"floor3e.html";quad= "34";"floor3e.html";quad = "41";"floor4w.html";quad = "42";"floor4w.html";quad = "43";"floor4e.html";quad = "44";"floor4e.html";"");
pinx := @DbLookup("Notes":"NoCache";"";"LocCoords";DeskLocation;2);
piny := @DbLookup("Notes":"NoCache";"";"LocCoords";DeskLocation;3);
@If(@Trim(@Text(pinx))="" |  @Trim(@Text(piny))="";@Do(@Prompt([Ok];"Aborting";"The desk information could not be located.");@Return(""));"");

@URLOpen(MapPath+mapFile + "?OpenPage&pinx="+@Trim(@Text(pinx)) + "&piny="+ @Trim(@Text(piny)))

I know that I have to make the field editable from a view and I know that you can put some script on the inviewedit of the view but this is a formula how do I make that work? Also I need to insure that it runs the code and doesn't put the field into edit mode. Some data that may be pertinent....I'm running my servers and apps on ND6.5, the field which has the desk location is a picklist......Thanks experts.......
Avatar of HappyFunBall
HappyFunBall

Are you saying you want this formula to run from a button in a view?  In other words, a user selects a particular document in a view (the appropriate 'desk location') and then clicks a button to launch the map?

If that's the case, you can just take this formula and put it in an agent that runs on selected documents.  Then set your button to run the agent.  The formulas should act on the selected document and grab the DeskLocation field from that document.  
Not sure what you are trying to accomplish.  Why do you need in place editong for this?  There are a number of ways to accomplish it...

1) An action button on the view that the user clicks, same as the user would click o the form.  It will execute against whatever doc is highlighted

2) If the view is supposed to not allow the user to open the doc, use QueryDOucmentOpen on the voiew, and trap user opening.  You cna then have your script: launch the URL; and, cancel the doc open

There are other variations as well.
Avatar of Ray Padilla

ASKER

Sorry not what I'm looking for, I have a view that displays the name, desk location and other information on the employee, what I want is to be able to click on the desk location on the view for that particular record and have it launch the code, as you know in 6.5 you can edit a record within the view, I just want to launch the code instead of opening that filed for editing.....I hope I've better explained it...
Wait, I get it.  The user has to pick a desk location before click the button, right?  The simple way:

Have your view action button, as described in #1 above

Then, the button DISPLAYS a list of desks -- via @Prompt([OKCancelList]; ... ) -- which obviates the need for in place editing.
I'll take any option that will open the map from within the view, the users have access to open the form and view it (they can see the employees picture there) but the request is not to have to open the record in order to launch the map.
help me out qwaletee, create an action button that runs on the selected record? do I just copy the code to the button? will this then launch the maps?
this is what I've done, I created an agent by copying the formula onto the agent, I set the agent to run on selected documents, then I created an action button on the view with the following code:
 @Command([ToolsRunMacro]; "View Desk Location"); Nothing happens, the agent runs but nothing happens. Am I missing something?
If I read you correctly, you want to be able to launch the document associated with a location. You want to eliminate the need of opening the document.

You can do it only with a view, but you will lose the ability to display the user friendly map.

Create a form, call it FormA. Add two fileds in it. One will represent your locations and the other a friendly readable text representing it.

With this form create some location document and add appropriate values. YOu can take hint from your existing form and see what values are given there. Ultimately your objective is to generathe the values for the variable quad.

Now create a view that is based on this form. Mark the first field as HTML text. Format the field content in such a way that it generates the link to the correct location as you want.

Get rid of your Agent. It will not be needed as the view will generate the necessary links.
The user friendly map is the function I want to make more readily available to our users. Whne the button is clicked on the form it opens the map and runs the java agent that "points" to the employees desk on the map, but you have to open the form in order to get to this button. On the view I have the lastname, firstname, phone number, desk location, title, department, managers name........From the view clicking on the desk location of a particular employee should fuction as the button on the form. I know that there is an inviewedit which I can use to run some script, I want the script to launch the button code for that individual form...
1. if the name of the field that holds the desk location is not "DeskLocations", say it's "DeskLoc" (check the formula used for the picklist in the form that currently works fine)
2. put the line <<DeskLocation := DeskLoc;>> at the beginning of your formula and put the line <<@Command( [FileCloseWindow] );>> at the end of your formula
3. put the new formula in the QueryOpen event of the form of the desk locations documents
4. now, if you double click the desk location document, the formula should open the URL

Well, it's better if you replace my previous point 3. with the following:
3.1. add a new Launcher form; it should be completely empty except for a Computed for display field, always hidden, with the formula <<SaveOptions := "0">> inside, and put the formula from point 2. in its QueryOpen event
3.2. in the FormFormula object of the Desk Locations view write <<"Launcher">>

Create an action button in the view with the following code -- except that you need to provide the list of available desk locations in the first line, either via hard-coding, or @DBLookup, or something...

AvailableDesklocations := ****************multi-value-text-list-returned-here************;
tempDeskLocation := @Prompt([OKCancelList]; "Desk Location"; "Choose a desk location:"; DeskLocation; AvailableDesklocations);
mapPath := "file:\\server\\folder\\folder\\folder\\folder\\";
@If(@Trim(tempDeskLocation)="";@Do(@Prompt( [Ok];"Aborting";"The Desk Location Field is Blank.");@Return(""));"");
quad := @Text(@Left(tempDeskLocation;2));
mapfile := @If(quad = "11";"floor1w.html";quad = "12";"floor1w.html";quad = "13";"floor1e.html";quad = "14";"floor1e.html";quad = "21";"floor2w.html";quad = "22";"floor2w.html";quad = "23";"floor2e.html";quad = "24";"floor2e.html";quad = "31";"floor3w.html";quad = "32";"floor3w.html";quad = "33";"floor3e.html";quad= "34";"floor3e.html";quad = "41";"floor4w.html";quad = "42";"floor4w.html";quad = "43";"floor4e.html";quad = "44";"floor4e.html";"");
pinx := @DbLookup("Notes":"NoCache";"";"LocCoords";tempDeskLocation;2);
piny := @DbLookup("Notes":"NoCache";"";"LocCoords";tempDeskLocation;3);
@If(@Trim(@Text(pinx))="" |  @Trim(@Text(piny))="";@Do(@Prompt([Ok];"Aborting";"The desk information could not be located.");@Return(""));"");

@URLOpen(MapPath+mapFile + "?OpenPage&pinx="+@Trim(@Text(pinx)) + "&piny="+ @Trim(@Text(piny)))
Your agent woudl probably also work if you set it to target "None" and made sure to ask for a desk location, as I do in the first two lines of the code above.
FYI, here's why I did not go with InViewEdit:

1) I don't think there is any way to get it to display a drop down in the view

2) It is tricky to work with

3) It only works with LotusScript

4) It is not documented well

5) I've heard it is buggy
My previous solution finally works (I tested the @URLOpen part)!

1. the new formula reads as follows:
REM {********** BEGIN **********};

MapPath := "file:\\server\\folder\\folder\\folder\\folder\\";
DeskLocation := {put here the value, based on the current document if the DeskLocation field is not available};
quad := @Text(@Left(DeskLocation;2));
MapFile := @If(
  quad = "11";"floor1w.html";
  quad = "12";"floor1w.html";
...
  ""
);
@If( MapFile = ""; @Return( "" ); "" );
pinx := @DbLookup("Notes":"NoCache";"";"LocCoords";DeskLocation;2);
piny := @DbLookup("Notes":"NoCache";"";"LocCoords";DeskLocation;3);
@URLOpen( MapPath+mapFile + "?OpenPage&pinx="+@Trim(@Text(pinx)) + "&piny="+ @Trim(@Text(piny)));

REM {********** END **********};

2. add a new "Dummy" form, used for doing nothing (that's weird but it works)
  2.1. it should be completely empty except for a Computed for display field, always hidden, named "SaveOptions" and with the formula <<"0">> inside (this prevents document creation)
  2.2. put the sentence <<Continue = False>> inside the QueryOpen script (this prevents document opening)

3. add a new "URLOpener" view for the desk location documents
  3.1. in the FormFormula object write <<"Dummy">>
  3.2. put the formula in 1. into the QueryOpenDocument formula

4. now, if you double click the desk location document, the formula opens the URL properly
In this line of code how would I make it look into the form and see the desklocation field? I don't want the user to have to go through a picklist just click and go to the map by virtue of the desklocation already being selected. My understanding from this code is that when the user clicks on the desklocation in the view it will launch the map, is this because I will have changed the column on the view to a hyperlink? I'm sorry these may seem like dum questions but I'm trying to learn as I go. I'll give this a shot....Thanks
DeskLocation := {put here the value, based on the current document if the DeskLocation field is not available};
Note that my solution behaves as follows:

a. a Notes user opens the URLOpener view (which appears just like your desk locations view)
b. s/he finds the document for the location s/he wants to open and doubleclicks on it
c. the URL opens in a new browser window inside the Notes client (no document is opened)

----
The comment for DeskLocation may be superfluous or fundamental: it depends on your data.
I'll try to be clearer.

In the form currently used to open the URL, you said there is a picklist field for selecting the locations. You have to open that form in the Notes Designer and discover how that field is populated and, if keyword synonims are used, what they look like, because those values are used for building the final URL.
In the simplest case, a column of a view is used for populating a picklist field. But it may be different, up to a complex formula whose value is a list of strings.

If a column of a view is used, then you have to open that view in the Notes Designer and discover what appears in that column. In the simplest case, there is a single field name, but could be much more complex...

If there is a single field name in that column, then it could be DeskLocation, and if so, the <<DeskLocation := {...}>> line in my formula would be superfluous. But it could be any "OtherName", so the line should read <<DeskLocation := OtherName;>>
Just a little note: there is no hyperlink in the view, just Notes magic ;-)
Umm, padillr, I don't know what you are talking about anymore.  really basic question: You ask for a dropdown field, but then indicate that the field would already be filled in.  If it is already filled in, why would you need a dropdown field in the view (which I will repeat, is not possible even with in place editing)?

So, if the value will always be an existing value on the document, we can create butotn code that works one way.

And if we always expect the user to chose a desk location before clicking, then we can do it another way (the code for which I already provided).
the only "hole" I can think of is if the value may be filled in BUT the user can also select a new value before launching the map.  My code handles this as well, excpet there will be one extra click if the user wanted to use a pre-filled value unchanged.
padillrr, what about my solution?
YAAQ
I think padillrr was trying to change the behaviour of a chunk of a working application, probably developed by others.

description of the old behavior:
1. a user opens a document and selects an option from a list of locations
2. clicks on the action button "show" and a web page opens up with the location marked on a map

description of the new behavior:
1. a user selects a location document in a view
2. double clicks on the document and a web page opens up with the location marked on a map

If I am right then my comments solve the problem.
Actually, Raputa, that's now what he wanted... I think.  The description was unclear, but what I got in the end is that he wants two things to be possible -- pretend it is a web page, with two links per line.  One link opens the employee details.  The other link opens a map that pinpoints the employee location.  His thought was that you click on the location field, and use In-place Edit to create an "pen map" event (i.e., instead of allowing you to edit it just flies into the map).

And now, I think I've figured out a way to do that -- have different events initiated depending where in the row you click.  But I won't actually try it unless I can get confirmation from padillrr that this is what he wants.

(FYI, if this were a Domino web-based application, it would be trivial via passthru HTML.)
qwaletee, maybe I've found an alternative to my previous method that uses the InViewEdit, as suggested by padillrr... so here is a lesson to learn for me (and experts in general, I think): pay attention to what someone asks for and if it's unfamiliar to you, then pay double attention! InViewEdit is a feature I never used and I did think initially that padillrr was on the wrong path, but finally I've devised this method.

The main problem was that Notes Designer Help says you shouldn't use the QUERY_REQUEST event in Notes 6, so... use the special case instead!! Yes, something special happens if the column shows a value as an icon: The SAVE_REQUEST event is triggered as soon as the user clicks on the icon. So padillrr can follow these steps to get what s/he asked for in the first place (nonetheless my first method is a solution as well, but with the following method we can have more than one link for each row, and it's also a lot simpler). It works, I tested it.

1. at the left or right of the location column, add a new column for showing a field, and check both flags <<Display values as icons>> and <<Editable column>>. Does not matter what field you choose for this icon column, but to make things nicer, you can add an <<icon>> field to the documents, computed when composed, type number, with a constant value set to the icon you want to display, or 0 if you do not want any icon shown there

2. paste this sub as your <<Sub Inviewedit>>
---
Sub Inviewedit(Source As Notesuiview, Requesttype As Integer, Colprogname As Variant, Columnvalue As Variant, Continue As Variant)
' This view has one editable column, which is for display of an icon.
      
      ' Define constants for request types
      Const QUERY_REQUEST = 1
      Const VALIDATE_REQUEST = 2
      Const SAVE_REQUEST = 3
      Const NEWENTRY_REQUEST = 4
      
      ' Define variables
      Dim db As NotesDatabase
      Dim doc As NotesDocument
      Dim ws As New NotesUIWorkspace
      Dim caret As String
      
      ' Get the CaretNoteID - exit if it does not point at a document
      caret = Source.CaretNoteID
      If caret = "0" Then Exit Sub
      
      ' Get the current database and document
      Set db = Source.View.Parent
      Set doc = db.GetDocumentByID( caret )
      
      ' Select the request type
      Select Case Requesttype
            
      Case QUERY_REQUEST
            ' Reserved - do not use for Release 6.0
            
      Case VALIDATE_REQUEST
            ' Not used for icon columns
            
      Case SAVE_REQUEST
            Dim w As New NotesUIWorkspace
            w.UrlOpen doc.URL( 0 )
            Continue = False
            
      Case NEWENTRY_REQUEST
            
      End Select
End Sub
---
in my Notes 6.5.2 there is a little misfunction... the InviewEdit event is triggered relative to X coordinate of the mouse pointer, rather than to the X,Y position! And the Y coordinate is made equal to the highlighted document (not the checked document either). So whenever you click under the editable column but on the blank space below the last document in the view, the Inviewedit event is triggered for the highlighted document all the same :(
Hello everyone, sorry I haven't been active lately I have been involved in numerous projects......Tothe issue at hand I have pasted the code to the inviewedit on the view and have made the column editable however it is giving mesome errors 42, 1???
sorry my mistake........nothing seems to be happening.......am i missing anything?
have you already done what described in <<1. at the left or right of the location column, add a new column...>> ?
OK did everything and still nothing. I created the filed on the form (Icon) added the column, made it icon and editable etc.....how does the inviewedit know what code to run?
addendum: how does the inviewedit know to run the code that opens the webpage?
It's simple, you have to edit a little the code I posted... look this snippet
---
     Case SAVE_REQUEST
          Dim w As New NotesUIWorkspace
          w.UrlOpen doc.URL( 0 )
          Continue = False
---
here I opened the URL recorded in the URL field in the document... just adapt it to your need, or try
---
     Case SAVE_REQUEST
          Dim w As New NotesUIWorkspace
          w.UrlOpen "http://www.google.com"
          Continue = False
---
to see if it works
maybe something like
---
     Case SAVE_REQUEST
          dim result as Variant
          result = Evaluate( {
MapPath := "file:\\server\\folder\\folder\\folder\\folder\\";
<<DeskLocation := put here the value, based on the current document if the DeskLocation field is not available;>>
quad := @Text(@Left(DeskLocation;2));
MapFile := @If(
  quad = "11";"floor1w.html";
  quad = "12";"floor1w.html";
...
  ""
);
@If( MapFile = ""; @Return( "" ); "" );
pinx := @DbLookup("Notes":"NoCache";"";"LocCoords";DeskLocation;2);
piny := @DbLookup("Notes":"NoCache";"";"LocCoords";DeskLocation;3);
MapPath+mapFile + "?OpenPage&pinx="+@Trim(@Text(pinx)) + "&piny="+ @Trim(@Text(piny));
          }, doc )
          Dim w As New NotesUIWorkspace
          w.UrlOpen result( 0 )
          Continue = False
---
and remember what I said about the line marked <<DeskLocation := ...>> in my previous comments
this is what I have: Case SAVE_REQUEST
            Dim result As Variant
            result = Evaluate( {
MapPath := "file:\\orlfs03\\gen_user\\tsd\\iagprojects\\officelocator\\";
<<DeskLocation := "";@Do(@Prompt( [Ok];"Aborting";"The Desk Location Field is Blank.");@Return(""));"");
quad := @Text(@Left(DeskLocation;2));
MapFile := mapfile := @If(quad = "11";"floor1w.html";quad = "12";"floor1w.html";quad = "13";"floor1e.html";quad = "14";
"floor1e.html";quad = "21";"floor2w.html";quad = "22";"floor2w.html";quad = "23";"floor2e.html";quad = "24";
"floor2e.html";quad = "31";"floor3w.html";quad = "32";"floor3w.html";quad = "33";"floor3e.html";quad= "34";
"floor3e.html";quad = "41";"floor4w.html";quad = "42";"floor4w.html";quad = "43";"floor4e.html";quad = "44";"floor4e.html";"");
 @If( MapFile = ""; @Return( "" ); "" );
pinx := @DbLookup("Notes":"NoCache";"";"LocCoords";DeskLocation;2);
piny := @DbLookup("Notes":"NoCache";"";"LocCoords";DeskLocation;3);
MapPath+mapFile + "?OpenPage&pinx="+@Trim(@Text(pinx)) + "&piny="+ @Trim(@Text(piny));
          }, doc )    
            Dim w As New NotesUIWorkspace
            w.UrlOpen result( 0 )
            Continue = False

I'm getting an error at  ---->  },doc ) it's all in red
there is something weird here
---
<<DeskLocation := "";@Do(@Prompt( [Ok];"Aborting";"The Desk Location Field is Blank.");@Return(""));"");
---
what are you trying to do?
I really don't know I didn't write this code, it is in a button that opens this webpage based on the users desk location......
ASKER CERTIFIED SOLUTION
Avatar of Andrea Ercolino
Andrea Ercolino

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
and please tell me if the google page opened fine for you, it's important!!
also, is better if you check pinx and piny against possible errors, replace
---
pinx := ...
piny := ...
---

with
---
pinx := @DbLookup("Notes":"NoCache";"";"LocCoords";DeskLocation;2; [FAILSILENT] );
@If( pinx = ""; @Return( "" ); "" );
piny := @DbLookup("Notes":"";"";"LocCoords";DeskLocation;3; [FAILSILENT] );
@If( piny = ""; @Return( "" ); "" );
---
Wow it worked!!! now how do I get an Icon on that column ? You got the points