How to Fetch one function value to another function within Script Include?

kshitiz11
Tera Expert

I want to send one function(getOrderGuide) return value to second function(sendValues).

Please correct me if my approach is on track or i am missing somewhere.

Here is my script include.

var getOrderGuideValues = Class.create();

getOrderGuideValues.prototype = Object.extendsObject(AbstractAjaxProcessor, {

  getOrderGuide : function(test){                                                           //function 1

  var mahi = this.test;

  answer = this.getParameter('sysparm_value');

  return answer;                                                                                                                       //send this value to the "sendValues" function

  },

  sendValues : function(getOrderGuide){                             //function 2

  var value1;

  var value2 = getOrderGuide;

  if(...){

  //some code;

  }

  return value2;

  },

      type: 'getOrderGuideValues'

});

1 ACCEPTED SOLUTION

Alikutty A
Tera Sage

Hi Kshitiz,



You can use this code



var getOrderGuideValues = Class.create();


getOrderGuideValues.prototype = Object.extendsObject(AbstractAjaxProcessor, {



  getOrderGuide : function(test){                                                           //function 1


  var mahi = this.test;


  answer = this.getParameter('sysparm_value');


  var value = this.sendValues(answer);


  return value;                                                                                                                       //send this value to the "sendValues" function


},



  sendValues : function(getOrderGuide){                             //function 2


  var value1;


  var value2 = getOrderGuide;


  if(...){


  //some code;



  }


  return value2;


  },


      type: 'getOrderGuideValues'


});





Thanks


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


View solution in original post

3 REPLIES 3

Alikutty A
Tera Sage

Hi Kshitiz,



You can use this code



var getOrderGuideValues = Class.create();


getOrderGuideValues.prototype = Object.extendsObject(AbstractAjaxProcessor, {



  getOrderGuide : function(test){                                                           //function 1


  var mahi = this.test;


  answer = this.getParameter('sysparm_value');


  var value = this.sendValues(answer);


  return value;                                                                                                                       //send this value to the "sendValues" function


},



  sendValues : function(getOrderGuide){                             //function 2


  var value1;


  var value2 = getOrderGuide;


  if(...){


  //some code;



  }


  return value2;


  },


      type: 'getOrderGuideValues'


});





Thanks


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


amlanpal
Kilo Sage

Hi Kshitiz,



You can call the other function value from another function inside the same Script include as below. You can call getOrderGuide function from sendValues function itself.


var abc = this.getOrderGuide(Param1, Param2);


And define the Script include as below:


getOrderGuide: function(Param1, Param2){


//Do your logic


}



I hope this helps.Please mark correct/helpful based on impact


Hi kshitiz1,



If I have answered your question, please mark my response as correct so that others with the same question in the future can find it quickly and that it gets removed from the Unanswered list.


If you are viewing this from the community inbox you will not see the correct answer button.   If so, please review How to Mark Answers Correct From Inbox View