Thank you for supporting the Cloud Customer Connect Community in 2024. It's a gift to work with you!

Look back
You're almost there! Please answer a few more questions for access to the Applications content. Complete registration
Interested in joining? Complete your registration by providing Areas of Interest here. Register

Java script function return undefined

edited Jul 10, 2021 3:31AM in Visual Builder 4 comments

Content

Hello All,

My use case consists 1 function to call another function in js. But it keep returning undefined. 

I would like to know if i need to do a conversation or to get a work around. 

Please check sample code below and attached alert sreenshot

  PageModule.prototype.getResult1 = function () {
    var ep = Rest.get('role/getGetRole');
    var returnVal = 'Success';
    ep.fetch().then(function (result) {
      if (result.response.ok) {
        alert(result.body.count); //pass
        var resultResult = result.body.count;
        if (result.body.count == 4) {//pass
          return returnVal;// returnVal is undefined!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
        }
        return 'Not OK';
      }
      else {
        return null;
      }
    });
  };
 
  PageModule.prototype.getResult1Value = function (arg1)

Howdy, Stranger!

Log In

To view full details, sign in.

Register

Don't have an account? Click here to get started!