Function within Script Include is not working

Satpal Singh1
Kilo Contributor

Hello All,

I know this is very simple code in server side script but why it is not working I am very amaze.. .

gs.print('I am running '+ this._gettest('da','Hello Sir'));

function _gettest(target,query) {

  gs.print(target + query);

}

Thanks all !!

Regards,

SS

11 REPLIES 11

Calling script include using BR and within same script include function calling other function.


You can add this code in your script include



var MyScriptInclude = Class.create();


MyScriptInclude.prototype = {


  initialize: function() {


  },



  MyFunction : function(){


  this._gettest("script include", "test");


  },



  _gettest : function (target,query) {


  gs.log(target + query);


  },



  type: 'MyScriptInclude'


};



And call in from your BR



var me = new MyScriptInclude();


me.MyFunction();




Thanks


Please Hit like, Helpful or Correct depending on the impact of the response


Thanks for your response, However, I get response as undefined. When I call a function in the end I say



Return ('Hello Something');


Did the above code worked? I am not sure how you have written the return code



Thanks


Please Hit like, Helpful or Correct depending on the impact of the response


/////////////////// This is my Script Include ////////////


maintest: function() {




  var getva = this.getTest('da',agg.value);


gs.log(getva);



  },



  getTest: function(target,query) {


  try {



  return (target + query);


  }


  catch(ex) {


  var message = ex.getMessage();


  }



  },



BR///////////////////////////



var test = new TEST(); /// main Script Include


test.maintest();




This I am try to do .. but not working...