Hi,
I have a list with documents and when I open document, I need to get some information about the document using the code written in LS. I wrote scenario:
-
create temp doc and save
-
call agent(temp.getNoteID)
-
getDocumentByID(temp.NoteID) and use results
It works only if after step 2. I re-open page and I execute step 3 on page load.
Unfortunately this is not an option because I need quick operation and use partial-refresh. With this scenario at step 3. I do not have results of the agent execution. It does not work also if I split step 3 when sub-page is loaded.
I tried to call ‘delete’ on the document but it does not help.
What I would like the most would be scenario written on the top of the post in single server call but I need any solution that will give me results of LS execution without reloading whole page.
Thanks in advance,
Grzegorz
Subject: Could you send on your sample app to have a closer look?
Could you send on your sample app for us to have a closer look?Regards,
Paul.
paul_hannan@ie.ibm.com
Subject: workaround - i hope temporary
when I click button, I call web agent and wait for result as json - i have return value from agent. this is client JavaScript.
when i have result i am searching for another button and call click method.
- this is where my agent execution is complete and I have result values. I do not need temporary document for return value.
this second button executes my Server Side code…
I have not compared it with server side only execution but I belive that it will be slower due to additional server roundtrip.
Subject: workaround - final and nice
reopen database with code below and getDocumentByID will give you fresh document.
session.getDbDirectory(“”).openDatabase(database.getFilePath());
Subject: Could you give more informations ?
reopen database with code below and getDocumentByID will give you fresh document.
session.getDbDirectory(“”).openDatabase(database.getFilePath());
compared to the code shown above, where is this line?
I have the same problem, in
getComponent(“Numero2”).setValue( document1.getItemValueString(“Numero”));
document1.getItemValueString(“Numero”)
dont retrieve backend document field data…
Subject: the code
place button on xpage and place this code in event handler.
// create and save temporary document (can be existing, depends on you)
var a:NotesAgent = database.getAgent(‘returnSomething’);
var doc:NotesDocument = database.createDocument();
doc.replaceItemValue(“Form”,“testAgent”);
doc.save();
// get note id
var noteId:String = doc.getNoteID();
// run agent. the agent takes ParameterNoteID, set some fiels and save document
a.runOnServer(noteId);
// the same document - not possible to get values from agent execution…
var docret = database.getDocumentByID(noteId);
getComponent(‘inputText1’).setValue( docret.getItemValueString(‘somevalue’));
agent returnSomething
Sub Initialize
Dim s As New NotesSession
Dim agent As NotesAgent
Set agent = s.CurrentAgent
'get document created by xpage
noteId$ = agent.ParameterDocID
Dim doc As notesdocument
Set doc = s.CurrentDatabase.GetDocumentByID(noteId$)
' set value and save
Call doc.ReplaceItemValue("somevalue","hello")
Call doc.Save(True, False)
End Sub
Subject: This is interesting… please keep us updated.
Subject: UPDATE | This is not a bug
After investigation by the team is was concluded that this is not related to XPages but to the Backend classes. Also this is not a bug as the backend maintains a list of opened document and returns the same document instance from the same session, until the document is actually discarded. A call to recycle() should be done before calling the agent in order to get ot properly working
Subject: I’ve created a bug for this as a placeholder - PHAN7QMBRU - though this might change after further investigation xp:eom/