Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7779779
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T18:43:35+00:00 2026-06-01T18:43:35+00:00

Using 8.5.3 UP1. I’m having an issue with an SSJS script library that I

  • 0

Using 8.5.3 UP1. I’m having an issue with an SSJS script library that I am using for “hide/whens” or more exactly in xpages “show/ifs”. In any case the global variables seem to take the value of the last time I saved the script library. They don’t seem to compute based on the documents current value. Is this a known thing (obviously not known to me.). Here is a sample page and script library to demonstrate the issue:

Example XPage:

<xp:this.resources>
    <xp:script src="/ssjsVisTest.jss" clientSide="false"></xp:script>
</xp:this.resources>
<xp:inputText id="inputText1" value="#{document1.StatusTX}"></xp:inputText>
<xp:br></xp:br>
<xp:br></xp:br>
<xp:br></xp:br>
<xp:button value="Save" id="SaveBtn">
    <xp:eventHandler event="onclick" submit="true"
        refreshMode="complete">
        <xp:this.action>
            <xp:saveDocument var="document1"></xp:saveDocument>
        </xp:this.action>
    </xp:eventHandler>
</xp:button>
<xp:br></xp:br>
<xp:br></xp:br>
<xp:label id="label1" value="Status is Draft"
    rendered="#{javascript:statusVisibleDraft()}">
</xp:label>
<xp:br></xp:br>
<xp:br></xp:br>
<xp:label id="label2" value="Status is Pending"
    rendered="#{javascript:statusVisiblePending()}">
</xp:label>
<xp:br></xp:br>
<xp:br></xp:br>
</xp:view>

Sample SSJS script library:

var status = document1.getItemValueString('StatusTX');

function statusVisibleDraft() {

x = (status == "Draft") ? 1 : 0;

if(x > 0) {
    return true;
} else {
    return false;
}
}

function statusVisiblePending() {

x = (status == "Pending") ? 1 : 0;

if(x > 0) {
    return true;
} else {
    return false;
}
}

Any ideas? Thanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T18:43:37+00:00Added an answer on June 1, 2026 at 6:43 pm

    Variables in script libraries are transient in nature. Depending on system load the libraries might get unloaded between calls. The right place for global variables are the scopes (this is what they are made for). In your example it seems the view scope would be appropriate. Also Sven is right about computation. Furthermore it is good practise not to have side dependencies. If you add another data source with a different name you can’t reuse your ssjs lib. You would hand over the data source as parameter e.g. in beforeRenderResult:
    setstatusDraftVisible(document1,’Status’,’draft’)
    Inside such a function you check if the field (2nd param) exists and has the value of the 3rd param and then set:
    viewScope.statusDraftVisible=true; // or false

    Then you have rendered=”#{JavaScript:viewscope.statusDraftVisible}”

    When your application is more complex and you have a lot of these checks, you might consider a viewScope ‘backing bean’ aka managed bean. This could reduce rendered to
    rendered=”#{beanName.statusDraftVisible}”

    Which is faster.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Using 8.5.3 UP1 with the Hotfix for the multi-rich text control issue. I am
Using 8.5.3 UP1 When I save my document from a dialog box certain fields
Using Nunit, I want to be able to write a test fixture that will
Using top it's easy to identify processes that are hogging memory and cpu, but
Using the navigator.geolocation object in JavaScript. Trying to establish accurate ranges, but wondering exactly
I'm Using 8.5.3 UP1 and I really like the extension libraries dynamicViewPanel but I
I have an issue with having a asp.net Grid View loaded into a div
I've been attempting to architect a server side API that runs using a noSQL
Using report builder 3.0, I have a report that queries a cube. How do
Using Entity Framework CodeFirst, how do I create a created datetime column that gets

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.