This forum is closed to new posts and responses. Individual names altered for privacy purposes. The information contained in this website is provided for informational purposes only and should not be construed as a forum for customer support requests. Any customer support requests should be directed to the official HCL customer support channels below:

HCL Software Customer Support Portal for U.S. Federal Government clients
HCL Software Customer Support Portal



Feb 24, 2016, 10:07 PM
453 Posts
topic has been resolvedResolved

Calling a function in a separate JS file

  • Category: Server Side JavaScript
  • Platform: All
  • Release: 9.0.1
  • Role: Developer
  • Tags:
  • Replies: 1

I have posted this on Stackoverflow as well but thought there might be someone here that could help

I have a button on an XPage that calls the function thisAction. The Page has the resource jsMain loaded and it contains the code below

 

function thisAction(msg:String){
    try{
    include ('jsSave.js')
    switch(msg){
    case "Save" :
        print("This action = " + msg);
        if (processAction()){
            print("processAction returned true");
            return true;
            break;
        }else{
            print("processAction returned false");
            return false;
            break;
        }
    default:
        print("In default msg is " + msg);
        return false;
        break;
    }
    }catch(e){
        print("thisAction Failed in jsMain " + e.toString())
    }
}

I have another js Script library called jsSave that has a function processAction. If I add the jsSave resource to my calling page all works well. However, for reasons that I wont go into I don't want to add the resource to my page but want to add it to my code in jsMain. The compiler wont accept the include statement though documentation I have found on line would suggest that it should be OK. I have found some examples where they modify the document header but I can't alter the source page. 

Any ideas?

Feb 26, 2016, 3:45 PM
453 Posts
The answer is easy

just add

import jsSave 

now all functions in the library jsSave are available in this library. No () "" or extension necessary.

 


This forum is closed to new posts and responses. Individual names altered for privacy purposes. The information contained in this website is provided for informational purposes only and should not be construed as a forum for customer support requests. Any customer support requests should be directed to the official HCL customer support channels below:

HCL Software Customer Support Portal for U.S. Federal Government clients
HCL Software Customer Support Portal