I have created 2 functions. I call "findTitleNew" from "createNewOne". I reach a document in "createNewOne" function but when i return to function "findTitleNew" I lost the document that was found in "findTitleNew" How to continue without losing that document? NOTE: This functions are generic because I use those functions more than once in applications.
<xp:button value="Create" id="btnCreate">
<xp:eventHandler event="onclick" submit="true"
refreshMode="complete" immediate="false" save="true">
<xp:this.action><![CDATA[#{javascript:createNewDoc(document1)}]]></xp:this.action>
</xp:eventHandler>
</xp:button>
function findTitleNew(currDoc:NotesXSPDocument)
{
try
{
var dbOther1:NotesDatabase = session.getDatabase(database.getServer(),sessionScope.kontak_db_Path);
if (currDoc.getItemValueString("UNID")!="")
{
var otherDoc:NotesDocument = dbOther1.getDocumentByUNID(currDoc.getItemValueString("UNID"))
}
}
catch (e)
{
requestScope.status = e.toString();
}
}
function createNewOne(docThis:NotesXSPDocument)
{
try
{
//do stafff
findTitleNew(docThis)
//do stafff
}
catch (e)
{
requestScope.status = e.toString();
}
}
Any suggestion is appreciated.
Cumhur Ata
My SSJS is really rusty and it's a little hard for me to tell exactly what you want BUT you say : "I lost the document that was found in "findTitleNew" How to continue without losing that document? "
your function "findTitleNew" doesn't return anything. So if you get a document there you can work with it, but if you want to do move in the "createNewOne()" function you need to return the found document
if (currDoc.getItemValueString("UNID")!="")
{
var otherDoc:NotesDocument = dbOther1.getDocumentByUNID(currDoc.getItemValueString("UNID"))
return otherDoc;
}
Then :
function createNewOne(docThis:NotesXSPDocument)
{
try
{
//do stafff
var returnDoc = findTitleNew(docThis);
if (null != returnDoc) {
// do stuff with returnDoc here...
}
//do stafff
}
catch (e)
{
requestScope.status = e.toString();
}
}