Solved

Fill in a author field via the web interface

Posted on 2002-05-15
25
747 Views
Last Modified: 2013-12-18
Hi experts,

I have created a web enabled database. In the form that can be opened on the web I want the user to select a name (or group)from the Directory (NAB) and put this name (or group) in a author field using a dropdown dialog on the form.
When I want to do this directly in the author field, it's not possible, because you can't make a "list" of users in the author field.
Then I have tried to create a "dialog" text field whith a @DbColumn formula that is extracting a list of names from de names.nsf on the server, but this is not allowed on the web.

Who has any suggestion to do this ?

Greetings,

Bob
0
Comment
Question by:oosterbaan
  • 9
  • 7
  • 4
  • +2
25 Comments
 
LVL 10

Expert Comment

by:zvonko
ID: 7011895
Hi Bob,

@DbColum is allowed, but you get the problem with the 64KB limit :-)

Look into mail50.ntf for the Form "(wAddress)" for how to do.

You need something like:
@DbCommand("Domino"; "LoadAddressListByName"; NABs; "EntryList"; "20"; FindText);

Here an old discussion about this topic:
http://www.experts-exchange.com/questions/Q.20179160.html

0
 
LVL 9

Expert Comment

by:Arunkumar
ID: 7011925
Big Points huh ?
0
 
LVL 1

Author Comment

by:oosterbaan
ID: 7011932
Yeah...really needs a solution for this... (-:

I'll take a look at it Zvonko
0
 
LVL 24

Expert Comment

by:HemanthaKumar
ID: 7011996
0
 
LVL 8

Expert Comment

by:Jean Marie Geeraerts
ID: 7013031
Hey Bob,
This is something I've done using a combination of a LookupForm, an agent and JavaScript.

I'll try to explain it all here, but it would be easier if I could send you an example .nsf by email.

I use two different dialog forms : One simple where you can only select one name and one more complex where you can add/remove names to a list and then pass this list back to the field.

Here's the explanation for use with the form to select only one name. If needed I will post the info about the more complex multiple selection form here too. But I'd prefer to send it to you by email.
1) Create the form using the following definitions:
Form name : (SimpleSearchDialog)
Hidden fields :
  Query_String_Decoded
    Computed when composed text field
    Formula :
      Query_String_Decoded
    This field is used to pass the calling URL
  Field
    Computed when composed text field
    Formula :
      @RightBack(Query_String_Decoded; "&field=")
    This field will hold the name of the field to pass the results to.
  valuesSearchResults
    Computed text field with multiple values allowed
    Formula :
      valuesSearchResults
    This field is used to store the search results from the agent and will pass these to the selection box.

Visible fields:
  SearchCriteria
    editable text field
    onKeyDown contains the following code :
      return isEnterPressed(event);
    This field is used to enter part of the name to lookup
  SearchResults
    editable Listbox with multiple values allowed
    Formula for choices:
      valuesSearchResults
    onDblClick contains the following code :
      returnValues();
      window.close();

Button to perform the search contains the formula:
  @Command([FileSave];

Form events:
  WebQuerySave
    @Command([ToolsRunMacro]; "WebQuerySave-SimpleSearchDialog")
  JS Header
    // This function will write the selected value back to the parent document
    function returnValues()
      {
      var form=document.forms[0];
      var source=window.opener.document.forms[0];
      var sourceElements=source.elements;

      for (i=0; i<sourceElements.length; i++)
        {
        if (sourceElements[i].name==form.Field.value)
          {
          sourceElements[i].value=form.SearchResults.options[form.SearchResults.selectedIndex].text;
          }
        }
      }

    // This function will catch the enter key to prevent an unvolunteered save of the document
    function isEnterPressed( e )
      {
      var charCode = (navigator.appName == 'Netscape') ? e.which : e.keyCode;
      if (charCode=='13')
        return false
      else
        return true;
      }

2) In the forms where you want to lookup a name put the following code in JS Header :
// call agent to lookup the name entered in the field
// args :
//    field : the field to pass the values to/from
//    dialog : simple (select one name) or full (add/remove multiple names)
function lookupName(field, dialog)
      {
      var lookup=field.value;
      var pathname = window.location.pathname;
      filename = pathname.substring(0,(pathname.lastIndexOf('nsf')+3))

      if (dialog=="full")
            window.open(filename + "/SearchDialog?OpenForm&field=" + field.name, "lookup", "height=330,width=650")
      else
            window.open(filename + "/SimpleSearchDialog?OpenForm&field=" + field.name, "lookup", "height=340,width=420");
      }

// Opens the passed url in a new window
function openWindow(url)
      {
      window.open(url, "newWindow", "scrollbars=yes, resizable=yes, maximized=yes")
      }

// Check what type of key is pressed
// This funciton is used to prevent key entry in lookup-fields
// args:
//   e : the passed event
// returns:
//   false : key is not ALT(18), CTRL(17) or TAB(9)
//   true : key is not ALT, CTRL or TAB
function regularKey(e, msg)
      {
      var charCode = ( navigator.appName == "Netscape" ) ? e.which : e.keyCode;
            
      if (charCode==9 || charCode==17 || charCode==18)
            return true
      else
            {
            alert(msg);
            return false;
            }
      }

These functions are used to open the search dialog in a new window and the functin regularKey can be used to prevent the user from manually typing a name in the field.
Behind the field in which you want to lookup a name put an action hotspit with the following JavaScript code:
    lookupName(document.forms[0].NameOfTheField, "simple");

To prevent the user from entering anything in the field put the following code in the onKeyDown event of the field:
    return regularKey(event, "Please use address search dialog to add/remove names");
    return false;

3) Use the following agent to lookup the names from the address book and return the values to the field valuesSearchResults :

(Declarations)
REM ===========================================================================
REM Global declarations
REM ===========================================================================
Dim session As NotesSession
Dim agent As NotesAgent
Dim db As NotesDatabase
Dim agentLog As NotesLog
Const LogFile$="logs/agents.nsf"
Dim LogServer As String

Dim searchDoc As NotesDocument
Dim nab As NotesDatabase
Dim peopleView As NotesView
Dim found As NotesDocumentCollection

Sub Initialize
      REM ========================================================================
      REM Initialize session and variables
      REM ========================================================================
      Set session = New NotesSession
      Set agent=session.currentagent
      Set db=session.currentdatabase
      LogServer=db.Server
      
      REM ========================================================================
      REM open agentlog and define error routine
      REM ========================================================================
      Set agentLog = New NotesLog(db.Title + " - " + agent.name)
      Call agentLog.OpenNotesLog(LogServer$, LogFile$)
      On Error Goto LogError
      
      REM ========================================================================
      REM initialize variables
      REM ========================================================================
      Set searchDoc=session.DocumentContext
      
      REM ========================================================================
      REM Lookup the names in the address book and add them to the values field
      REM ========================================================================
      Call lookupSearchString
      
      REM ========================================================================
      REM close agent log and leave sub
      REM ========================================================================
      Call agentLog.close
      Exit Sub
      
      REM ========================================================================
      REM Error routine : logs an error and resumes on the next line
      REM ========================================================================
LogError:
      Call agentLog.logerror(Err, "Initialize: " + Error$ + " in line " + Cstr(Erl))
      Resume Next
End Sub

Sub lookupSearchString
      REM ========================================================================
      REM This sub will lookup the names matching the criteria found in the field SearchCriteria and add
      REM the result to the field valuesSearchResults.
      REM This field holds the options to display in the SearchResults field.
      REM ========================================================================
      
      REM ========================================================================
      REM Define local error routine
      REM ========================================================================
      On Error Goto LogLocalError
      
      REM ========================================================================
      REM Local variables
      REM ========================================================================
      Dim foundNames() As String
      Dim personDoc As NotesDocument
      Dim tmpName As NotesName
      Dim i As Integer
      
      REM ========================================================================
      REM Lookup matches for the partial name in the address book
      REM ========================================================================
      If searchDoc.SearchCriteria(0)<>"" Then
            Set nab=New NotesDatabase("","")
            Call nab.Open("", "names.nsf")
            Set peopleView=nab.GetView("($Users)")
            Set found=peopleView.GetAllDocumentsByKey(searchDoc.SearchCriteria(0), False)
            If found.Count<>0 Then
                  Redim foundName(found.Count-1)
                  i=0
                  Set personDoc=found.GetFirstDocument
                  Do While Not personDoc Is Nothing
                        Set tmpName=New NotesName(personDoc.FullName(0))
                        foundName(i)=tmpName.Abbreviated
                        i=i+1
                        Set personDoc=found.GetNextDocument(personDoc)
                  Loop
                  searchDoc.valuesSearchResults=foundName      
            Else
                  searchDoc.valuesSearchResults="-no matches found-"
            End If
      End If
      
      Exit Sub
      REM ========================================================================
      REM Local error routine
      REM ========================================================================
LogLocalError:
      Call agentLog.LogError(Err, "lookupSearchString: " & Error$ & " in line " & Cstr(Erl))
      Resume Next
End Sub

4) For the agent to be able to write to the error log, create an agent log database on your server in the directory logs and call it agents.nsf (The filename of the logfile is actually defined in the Declarations section in the constant LogFile$)

This mechanism will when you click the hotspot open a new window with the (SimpleSearchDialog) form. You then lookup the name in this form by typing part of the name and then clicking on the button (for ease of use call it search).
The search results will then be displayed in a selection box in which you can double click on the name you want.
The search form will then automatically pass the selected value to the field and close.

I hope this explanation is clear enough, if not let me know and I will send you a little sample database with the search forms and agents and a little sample form to lookup one or more names.

Regards,
JM
0
 
LVL 8

Expert Comment

by:Jean Marie Geeraerts
ID: 7013035
Drop me an email at jean-marie.geeraerts@philips.com and I will send a reply with a little demo app you can use. (will save you the time of having to create the forms and type in or copy/paste the code from here)
0
 
LVL 8

Expert Comment

by:Jean Marie Geeraerts
ID: 7013037
Oh yeah, also foresee a cleanup agent to remove all the search forms from your database.
Just use a scheduled agent you call 'Cleanup'.
Have it run on all documents in the database and add as extra search criterium uses the "(SearchDialog)" or "(SimpleSearchDialog)" form and use the simple action Delete document to remove them.

You need to save the search document to be able to pass the search results to the listbox.
0
 
LVL 1

Author Comment

by:oosterbaan
ID: 7014469
Hi Jerrith,

I have send you a email for the sample database...!!!

Thx
0
 
LVL 8

Expert Comment

by:Jean Marie Geeraerts
ID: 7015680
Okay, the sample db is underway through cyberspace :-)
0
 
LVL 24

Expert Comment

by:HemanthaKumar
ID: 7016021
Bob, do you ever listen to other experts commenting on your questions. I have a strong belief that you never respond to few.

Sorry to say, if that is the case soon you will be loosing lots of resources on this forum.
0
 
LVL 8

Expert Comment

by:Jean Marie Geeraerts
ID: 7016075
Hey Hemanth,
I checked out your solution and it modifies the design of the domino directory, which I don't like to do.
When I tried to paste the $$SearchTemplate into my address book on my test server I got the following error message :
"This database or template has been authorized for use by Lotus Notes Mail users. This action will invalidate the authorization. Are you sure you would like to proceed?"

This made me doubt to continue. Can you explain what this message means and if it can be ignored?
0
 
LVL 10

Expert Comment

by:zvonko
ID: 7016164
It mean that basic templates are signed to be used by a low price client: the mail only client

Nowadays there are no dumb mail clients; all user pay a CAL
So is this restriction only for some R4.x clients or even older :-)

Read more here:
http://www.lotus.com/products/r5web.nsf/websecondary/Notes+buy+it?OpenDocument

0
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
LVL 10

Expert Comment

by:zvonko
ID: 7016167
But beside this is always a danger to change servers names.nsf design. At next upgrade you have to think about it :-)

0
 
LVL 24

Expert Comment

by:HemanthaKumar
ID: 7016170
It means that the database can not be used by Lotus Notes Mail users anymore (mail only license). For a Full Lotus Notes license this will not be a problem !
0
 
LVL 10

Expert Comment

by:zvonko
ID: 7016187
I have just tested Heman's proposed WebDoc name lookup. It is really cool! nearly the same as mail file web names lookup dialog :-)

(sorry; the one from SandBox is background blue <|;-)

0
 
LVL 1

Author Comment

by:oosterbaan
ID: 7017449
HemanthaKumar,

I'm trying to follow all the comments I'll get from the experts. I don't want to be rude, but I really need some time to figure out what they mean and often have to try things out a few days later, because I don't have much time for trying things out...

But, you're message is clear, I'll try to respond more for sofar possible.

Greetings,

Bob

0
 
LVL 1

Author Comment

by:oosterbaan
ID: 7022214
Jerrith,

I have received your sample database and have tried to implement it in my database. I have copied all the design elements and started your sample demoform.
When I open this form on the web and try to do a search, no result are shown. All field are empty...

Then I put your database on the server (made no changes to it), signed it, and again tried you demoform, with the same result, no search results...

Do you have any suggestion to debug this ?

Greetings,

Bob
0
 
LVL 8

Accepted Solution

by:
Jean Marie Geeraerts earned 200 total points
ID: 7023287
Hello Bob,
Do you have an agentlog database in folder logs of your data directory of the server?
The agent that is used to lookup results and return them to the document opens this database to write debugging info if needed. The database needs to be present for the agent to work, though.

So, if not available, create a new agent log database based on the advanced template Agent Log (alog4.ntf).
Type any title you want, but make sure to put "logs/agents.nsf" as file name when creating the database.
(You may also use another location/filename if you want, but then you have to changes the Const LogFile$ in the script to point to the correct agent log database).

Most likely, this is the reason why you don't get any results.

Let me know how you go...
0
 
LVL 1

Author Comment

by:oosterbaan
ID: 7023376
Hi Jerrith,

I should follow my instinct more often (-: I did take a look at the code and indeed I saw the agents log entry's in it... Shame on me !!!

Get back to you later....

Thx....

P.S. The application looks very nice...
0
 
LVL 8

Expert Comment

by:Jean Marie Geeraerts
ID: 7023429
Thanks, thought that while at it, I could just as easily demonstrate the ease of making an application look good by using stylesheets :-)
0
 
LVL 1

Author Comment

by:oosterbaan
ID: 7025624
Hi Jerrith,

Great, it's working and looks very good. I'm so happy (-:

I have copied all your design elements to my database and created on my form a field called Contacts with the addressbook icon behind it.
This is working fine, but a few, maybe little, questions:

Where can I change or remove the background (the girl). I think your stylesheet have changed my form design.

On my form I'm using a field (dialog list) that is using "Refresh fields on keyword change". This isn't working anymore after implementing your solution.

Greetings,

Bob
0
 
LVL 1

Author Comment

by:oosterbaan
ID: 7025633
More than excellent Jerrith...

You have earned your points already (-:

Also thx to all the guys who also did give comments.

Greetings,

Bob
0
 
LVL 9

Expert Comment

by:Arunkumar
ID: 7025643
Good Show Buddy!
0
 
LVL 8

Expert Comment

by:Jean Marie Geeraerts
ID: 7026136
You're welcome. We're always glad to help, especially when it's appreciated.
0
 
LVL 8

Expert Comment

by:Jean Marie Geeraerts
ID: 12198237
Hello Bob,

If you are still at EE and listening in. Do you still have this sample database I sent you and can you mail it to me?
I've changed jobs since then and forgot to take it with me :-)

You can send it to my private email: jean-marie.geeraerts@skynet.be

Regards,

JM
0

Featured Post

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

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…
IBM Notes offer Encryption feature using which the user can secure its NSF emails or entire database easily. In this section we will discuss about the process to Encrypt Incoming and Outgoing Mails in depth.
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

759 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now