Is it possible to use scratchpad in script include and access that in catalog client script?

madhurk
Tera Contributor

Hi All,

I have a scenario where I need to save a value in g_scratchpad in script include. and use that in a onLoad catalog client script to see if the scratchpad has any values?

I am getting a browser error that g_scratchpad is not defined..

Regards,

Madhu

2 REPLIES 2

Chuck Tomasi
Tera Patron

g_scratchpad is only available if you are using a display business rule. What I recommend is using your script include to produce the CONTENT (primitive data or object) that goes in to g_scratchpad rather than assuming you have access to g_scratchpad in the script include. Example



var myScriptInclude = Class.create();


myScriptInclude.prototype = {


      initialize: function() {


      },



        buildObject : function() {


                  myObj = {};


                  // put stuff in the myObj here



                  return myObj;


        },



      type: 'myScriptInclude'


};



In the display BR, call it...



g_scratchpad = new myScriptInclude().buildObject();



Now the client script has access to all that.


Kalaiarasan Pus
Giga Sage

If the script include is getting called from client script, you should be able to pass its value to the script, similar to any other normal variable,



Are you trying to do that?