I have an xPages application that use a global variable in javascript. The global variable is a NotesDocument. When the xPage loads, it calls some Java code which populates the global Javascript var.
A bit later I extract some information from that global var and all is well. A bit later in the code I run a function from a Javascript library that tries to access that global var and it's null. I'm not sure why. Nothing else updates that global var.
Can someone point me in a direction to figure this out?
//This is the script library function that throws the null error:
var revoPayments =
{
// Calculate if the occupant should see the Revo Pay My Bill Link in the occ navigator
"renderPayMyBillRevo" : function()
{
var result = false;
try
{
// THIS IS WHERE THE GLOBAL VAR IS NULL
if( parseInt( gUserOccupantProfile.getShowRevoLink() ) == -1 )
result = true;
} catch (e)
{
print(e.message);
}
print( "result: " + result );
return result;
}
}
//This is the calling javascript from the xPage which works fine pulling all the values etc.
if( gUserOccupantProfile && gUserOccupantProfile !== "null" && gUserOccupantProfile !== "undefined" )
{
// ALL THESE VALUES ARE SET BECAUSE IT'S A VALID OBJECT
sessionScope.put( "OccupantUNID", gUserOccupantProfile.getDocUNID());
sessionScope.put( "Tenant_ID", gUserOccupantProfile.gettenant_id() );
sessionScope.put( "UnitRefNo", gUserOccupantProfile.getUnitRefNo() );
sessionScope.put( "Resident", gUserOccupantProfile.getResident() );
sessionScope.put( "FirstName", gUserOccupantProfile.getFirstName() );
sessionScope.put( "LastName", gUserOccupantProfile.getLastName() );
sessionScope.put( "CurrentUser", gUserOccupantProfile.getFirstName() + " " + gUserOccupantProfile.getLastName() );
sessionScope.put( "PropertyAddress", gUserOccupantProfile.getPropertyAddress() );
var tempStr = gUserOccupantProfile.getcurrent_balance();
tempStr = tempStr.replace( "$", "" );
tempStr = tempStr.replace( ",", "" );
sessionScope.put( "Current_Balance", tempStr );
sessionScope.put( "PropertyNo", gUserOccupantProfile.getPropertyNo() );
sessionScope.put( "PropertyName", gUserOccupantProfile.getPropertyName() );
sessionScope.put( "LastPaymentDate", gUserOccupantProfile.getLast_payment_date() );
sessionScope.put( "LastPaymentAmount", gUserOccupantProfile.getPayment_amount() );
gAPropertyProfile = eStarService.getPropertyProfile( sessionScope.get( "PropertyNo" ) );
// 09.15.2014 - Steven Rieger : added code to disable pay my bill for separate properties
// Default is to always display the option.
if( gAPropertyProfile.getDisablePayMyBill().toLowerCase() == "yes" )
sessionScope.put( "renderPayMyBill", false );
else
sessionScope.put( "renderPayMyBill", true );
sessionScope.put( "renderStatements", myEStatements.renderStatements() );
print( "Before RenderRevo" );
// THIS LINE FAILS BECAUSE IN THE SCRIPT LIBRARY CODE ( SEE ABOVE ) THE
// GLOBAL VAR IS NULL
sessionScope.put( "renderPayMyBillRevo", revoPayments.renderPayMyBillRevo() );
print( "After RenderRevo" );
// sessionScope.put( "dialogOopsTitle", "Debug!" );
// sessionScope.put( "dialogOopsMessage", "gotLogEntry: " + gotLogEntry );
// var dialogOops = getComponent( "dialogOops" );
// dialogOops.show();
}
gUserOccupantProfile !== "null" && gUserOccupantProfile !== "undefined"
togUserOccupantProfile !== null && gUserOccupantProfile !== undefined
. – Mike Clucknull
andundefined
values. Comparing against the strings won't help. That would be true if you did this:gUserOccupantProfile = "null"
, not if you did this:gUserOccupantProfile = null
. – Mike Cluck