Calling a script include function inside it's script include.

rbuff
Tera Contributor

Hi All,

Im trying to call a script include function inside it's script include.   I've attempted it already with no results.  

I was wondering if it was even possible to do what I'm attempting in a script include?

1 ACCEPTED SOLUTION

Chuck Tomasi
Tera Patron

Hi Justin,



Reference functions with this.functionName().



Example:



var foo = Class.create();


foo.prototype = {


      initialize: function() {


      },



  bar : function() {


  this.zip(5);


  },



  zip : function(num) {


  gs.info('num=' + num);


  }


      type: 'foo'


};


View solution in original post

5 REPLIES 5

Chuck Tomasi
Tera Patron

Hi Justin,



Reference functions with this.functionName().



Example:



var foo = Class.create();


foo.prototype = {


      initialize: function() {


      },



  bar : function() {


  this.zip(5);


  },



  zip : function(num) {


  gs.info('num=' + num);


  }


      type: 'foo'


};


Thanks, Chuck!   Exactly what I was looking for.


Hi Chuck, ctomasi



We don't use this in business rule. Also in script includes sometimes we use "this" and sometimes not. For example please see below code taken from a script include. updateClassIfExists is being called without "this" but _generateProfilesFromType is being called with "this", kindly tell the difference?



generateProfilesFromType: function(type, updateClassIfExists) {


return this._generateProfilesFromType(type, updateClassIfExists); },



Regards


Ramandeep


I suspect the first instance is being used as a callback or reference. You're not calling the function outright, but rather passing it as a variable to another function (generateProfilesFromType). You're doing it again in the second one too....



If your code is calling the function/method directly, you need this.functionName, but if you're passing it as a parameter, then you don't.