2

I am working on a customization for one of the Maximo Anywhere Applications, built on the IBM MobileFirst Platform.

I have implemented a custom JavaScript file, and am able to call the functions directly through the app.xml. However, I am unable to call functions contained in this file from other JavaScript Functions. Can you not make calls like this? Any assistance would be appreciated.

Please see the simplefied example below. This would fail on the call to the retNewVal function from the callFromApplication function.

simplified example:

callFromApplication: function(eventContext){
    var selectedResource = eventContext.getResource().getCurrentRecord();
    var val1 = 5
    var val2 = retNewVal(val1);
    selectedResource.set('property1', val1);
    selectedResource.set('property2', val2);    
},

retNewValue : function(val){
    return val * 2;
},

Thanks!

Idan Adar
  • 44,156
  • 13
  • 50
  • 89
Dan F
  • 21
  • 2
  • What is the error message when it fails? – Arjun Aug 29 '16 at 17:12
  • Welcome to Stack Overflow. You can improve your question. Please read [Minimal, Complete, and Verifiable example](http://stackoverflow.com/help/mcve). When your code shows your precise problem with nothing extra, you are showing respect to those who volunteer to help you. – zhon Aug 29 '16 at 17:17

1 Answers1

4

It appears to me that you're calling the retNewValue function from within an object definition.

try adding a this. in front of it to ensure scope is properly maintained

var obj = {
    func1notworking: function() {
        func2("Doesn't Work");
    },
    func1working: function() {
        this.func2("Works");
    },
    func2: function(output) {
        alert(output);
    }
};

//obj.func1notworking();
obj.func1working();

JsFiddle

Justin MacArthur
  • 4,022
  • 22
  • 27