oosterbaan
asked on
Fill in a author field via the web interface
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
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
Big Points huh ?
ASKER
Yeah...really needs a solution for this... (-:
I'll take a look at it Zvonko
I'll take a look at it Zvonko
Here is a ready to use tool... check it out
http://www-10.lotus.com/ldd/sandbox.nsf/ecc552f1ab6e46e4852568a90055c4cd/f469e06a415a8dfc85256b1100532316?OpenDocument
~Hemanth
http://www-10.lotus.com/ldd/sandbox.nsf/ecc552f1ab6e46e4852568a90055c4cd/f469e06a415a8dfc85256b1100532316?OpenDocument
~Hemanth
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_De coded; "&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-SimpleSearch Dialog")
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.docum ent.forms[ 0];
var sourceElements=source.elem ents;
for (i=0; i<sourceElements.length; i++)
{
if (sourceElements[i].name==f orm.Field. value)
{
sourceElements[i].value=fo rm.SearchR esults.opt ions[form. SearchResu lts.select edIndex].t ext;
}
}
}
// 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,(path name.lastI ndexOf('ns f')+3))
if (dialog=="full")
window.open(filename + "/SearchDialog?OpenForm&fi eld=" + field.name, "lookup", "height=330,width=650")
else
window.open(filename + "/SimpleSearchDialog?OpenF orm&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].NameOfT heField, "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(LogS erver$, LogFile$)
On Error Goto LogError
REM ========================== ========== ========== ========== ========== ======
REM initialize variables
REM ========================== ========== ========== ========== ========== ======
Set searchDoc=session.Document Context
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.GetAllDoc umentsByKe y(searchDo c.SearchCr iteria(0), False)
If found.Count<>0 Then
Redim foundName(found.Count-1)
i=0
Set personDoc=found.GetFirstDo cument
Do While Not personDoc Is Nothing
Set tmpName=New NotesName(personDoc.FullNa me(0))
foundName(i)=tmpName.Abbre viated
i=i+1
Set personDoc=found.GetNextDoc ument(pers onDoc)
Loop
searchDoc.valuesSearchResu lts=foundN ame
Else
searchDoc.valuesSearchResu lts="-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
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_De
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-SimpleSearch
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.docum
var sourceElements=source.elem
for (i=0; i<sourceElements.length; i++)
{
if (sourceElements[i].name==f
{
sourceElements[i].value=fo
}
}
}
// 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,(path
if (dialog=="full")
window.open(filename + "/SearchDialog?OpenForm&fi
else
window.open(filename + "/SimpleSearchDialog?OpenF
}
// 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[
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(LogS
On Error Goto LogError
REM ==========================
REM initialize variables
REM ==========================
Set searchDoc=session.Document
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
Set nab=New NotesDatabase("","")
Call nab.Open("", "names.nsf")
Set peopleView=nab.GetView("($
Set found=peopleView.GetAllDoc
If found.Count<>0 Then
Redim foundName(found.Count-1)
i=0
Set personDoc=found.GetFirstDo
Do While Not personDoc Is Nothing
Set tmpName=New NotesName(personDoc.FullNa
foundName(i)=tmpName.Abbre
i=i+1
Set personDoc=found.GetNextDoc
Loop
searchDoc.valuesSearchResu
Else
searchDoc.valuesSearchResu
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
Drop me an email at jean-marie.geeraerts@phili ps.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)
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.
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.
ASKER
Hi Jerrith,
I have send you a email for the sample database...!!!
Thx
I have send you a email for the sample database...!!!
Thx
Okay, the sample db is underway through cyberspace :-)
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.
Sorry to say, if that is the case soon you will be loosing lots of resources on this forum.
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?
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?
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
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
But beside this is always a danger to change servers names.nsf design. At next upgrade you have to think about it :-)
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 !
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 <|;-)
(sorry; the one from SandBox is background blue <|;-)
ASKER
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
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
ASKER
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
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
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
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...
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...
Thanks, thought that while at it, I could just as easily demonstrate the ease of making an application look good by using stylesheets :-)
ASKER
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
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
ASKER
More than excellent Jerrith...
You have earned your points already (-:
Also thx to all the guys who also did give comments.
Greetings,
Bob
You have earned your points already (-:
Also thx to all the guys who also did give comments.
Greetings,
Bob
Good Show Buddy!
You're welcome. We're always glad to help, especially when it's appreciated.
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@skyne t.be
Regards,
JM
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@skyne
Regards,
JM
@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:
https://www.experts-exchange.com/questions/Q.20179160.html