janineo
asked on
How do I call a server side function and show results in a form?
Hello,
I am working in Lotus notes and have the following problem.
I have my own custom dll that I pass a parameter into which returns a URL. This dll needs to live on our server and cannot be ditributed. I call it using the following lotuscript (which all seems to work):
The problem I have is that I have a Lotus Notes form. Prior to showing the form to a user, I'd like to call a server side function (passing in a couple of variables from the document) that will return a string. I then need to embed this string into the document.
How should I go about doing this? I have thought about placing the lotus script above within an agent, and calling it via a form event but am unsure as to how to do this (or embed the resulting string).
Thankyou,
I am working in Lotus notes and have the following problem.
I have my own custom dll that I pass a parameter into which returns a URL. This dll needs to live on our server and cannot be ditributed. I call it using the following lotuscript (which all seems to work):
Dim myObj
Dim strInput As String
Dim strReturn As String
strInput = "test input string"
Set myObj=CreateObject("MyDLLName.clMain")
strReturn = myObj.EncryptMe(strInput, True)
The problem I have is that I have a Lotus Notes form. Prior to showing the form to a user, I'd like to call a server side function (passing in a couple of variables from the document) that will return a string. I then need to embed this string into the document.
How should I go about doing this? I have thought about placing the lotus script above within an agent, and calling it via a form event but am unsure as to how to do this (or embed the resulting string).
Thankyou,
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
> i.e form loads - agents is called - field on form is populated with this value.
Well, that isn't going to work. The form (NotesUIDocument) is local, whereas the agent runs on the server, so all data has to be communicated some way. The easiest way is through the document itself. So in fact, it's the other way around:
- call the agent (e.g. by means of a button)
- the agent creates the document with the url, on the server
- then open the document in a form
By the way: is the generation of the URL so special that you need to do it on the server, even by using a DLL?
Well, that isn't going to work. The form (NotesUIDocument) is local, whereas the agent runs on the server, so all data has to be communicated some way. The easiest way is through the document itself. So in fact, it's the other way around:
- call the agent (e.g. by means of a button)
- the agent creates the document with the url, on the server
- then open the document in a form
By the way: is the generation of the URL so special that you need to do it on the server, even by using a DLL?
ASKER
hello again
Yes I am afraid that our dll must reside on the server.
I have done something similar with webforms and utilised webqueryopen to call the server side agent which then updated a field on the page before it was served up to the client. I was hoping it would be feasible to do something similar with a standard form - ie. utilise the forms initialise method.
Yes I am afraid that our dll must reside on the server.
I have done something similar with webforms and utilised webqueryopen to call the server side agent which then updated a field on the page before it was served up to the client. I was hoping it would be feasible to do something similar with a standard form - ie. utilise the forms initialise method.
If the opened document has been saved on the server prior to calling the agent then you could pass the doc's universalID and get the agent to add the result directly and the browser just reloads the saved document.
> ... to do something similar with a standard form ...
Nope, not possible. In web much more is possible, also because everything runs on the server.
Apart from the agent-method I mentioned above, it could also be done using the NotesDocument.getDocumentB yURL method. With it, you might call an agent that creates and initialises a document through the HTTP-server of your Domino server. You can then update the document with the fields/items you need, and then open it to the user.
In any case, you have to create the document before you show it to the user. AFAIK, there is no way to call a server-side agent that returns its output to the client.
Best is to
- create a document
- call a server-side agent that initialises the document
- show the document to the user
Something like (I left out the declarations):
Nope, not possible. In web much more is possible, also because everything runs on the server.
Apart from the agent-method I mentioned above, it could also be done using the NotesDocument.getDocumentB
In any case, you have to create the document before you show it to the user. AFAIK, there is no way to call a server-side agent that returns its output to the client.
Best is to
- create a document
- call a server-side agent that initialises the document
- show the document to the user
Something like (I left out the declarations):
Set doc= New NotesDocument(db)
Call doc.Save(True, False)
Set agent= db.GetAgent("dllAgent")
Call ag.RunOnServer(doc.NoteId)
Call ws.EditDocument(doc)
And you might need to add a Call doc.Reload after line 4 indeed...
ASKER
thanykou sjef - it works!! :)
Ah, okay, good! Don't forget to have some cleanup-agent that removes unused temp documents, when someone doesn't save the document. And make sure that correctly saved documents aren't removed by the same agent...
ASKER
Thankyou for the comments...
Is it be feasible to add a new field to my original form and set it's value based on feedback from the agent? It seems a bit of a hack to create a new document and delete the old one.
i.e form loads - agents is called - field on form is populated with this value.
Also how do I go about calling an agent (passing in some parameters). I am new to notes so if you have a sample it will really help.