Help on "this" keyword in script include.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-08-2019 12:13 AM
Hello,
Can someone explain me on what scenarios do we use "this" in scrip include? I am aware that in the Ajax call we will use this.getParameter but I have also "this" key word for the sever call Script include.
Ex: this.user = request.caller_id;
I would like to understand on what cases/scenarios do we need to use "this" keyword?
Thanks,
Sunil
- Labels:
-
Best Practices
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-08-2019 12:31 AM
this is a JavaScript keyword which reference varies based on its context. In the case of Script Includes, it references the class object that the Script Include creates. You can use it to call other methods and properties of the class. So if you defined a method in the Script Include called 'getUser', you could call it in other methods with 'this.getUser();'. Likewise, if you define a property like 'this.user = "Sunil";' then you could access it with 'this.user'.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-08-2019 12:42 AM
Hi,
The keword this refer current context object.
refer below link for more information and example.
Mark as Correct/Helpful if you find help worthy.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-08-2019 06:04 AM
Hi,
this is a keyboard like a object. It holds glideRecords or other values in this which can be used anywhere in script once initialize.
in most of the script include we use this keyword for the fact that it can hold a data which can be used by other functions in that same script include.
Real time example:
1) Lets say i have a integration from which i am getting 100 records which i store in import set table and in my onBefore transform script in am calling a script include in which i pass source data which is used for validation.
2) In this script include we initialize this object in initialize function at start, which will be used by all other functions. SO basically my source Object from onBefore script goes into this initialise funtion and i set this to this keyword in different differen ways.
example:
Script include call:
var gr = new ScriptinlcudeName().functionName(source);
Script include:
initialize: function(gr) {
//gr is source
this.name = gr.name;//So name value in source will be associated with this.name and can be used in all script include function.
},
Thanks,
Ashutosh

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-09-2019 09:33 AM
Hi,
Any Update on this?
Thanks,
Ashutosh