g_scratchpad not working on UI Pages

jasongriffiths
Kilo Explorer

So I am using a business rule on the sys_ui_page table triggered on display.   I even tried removing all filter conditions and still get the following in my client script:

Uncaught ReferenceError: g_scratchpad is not defined

Any idea why this would be happening.   I found an older thread referencing a business rule that is apparently no longer OOB in Istanbul

.

7 REPLIES 7

jasongriffiths
Kilo Explorer

I am using a business rule on the sys_ui_page table that is trigger on "display".



(function executeRule(current, previous /*null when async*/) {



    var util = new SMDBUtil();
    var limit = parseInt(util.getEnvProperty('com.xxxx.quicksearch.results.max'));

    g_scratchpad.limit = 'Note: QuickSearch is limited to ' + limit + ' results.';
    g_scratchpad.test1 = 'test';

})(current, previous);



client code:



$j("#QuickSearchLimit").text(g_scratchpad.test1);



also get the same error when attempting:


console.log(g_scratchpad.test1);


Oh interesting.   I thought you were trying to use the g_scratchpad within the markup or client script of an instance of a UI Page.



I'm guessing this should still work:



(function executeRule(current, previous /*null when async*/) {



    var util = new SMDBUtil();


    var limit = parseInt(util.getEnvProperty('com.xxxx.quicksearch.results.max'));




    //g_scratchpad.limit = 'Note: QuickSearch is limited to ' + limit + ' results.';


    gs.getSession().putClientData('limit', 'Note: QuickSearch is limited to ' + limit + ' results.');


    //g_scratchpad.test1 = 'test';


    gs.getSession().putClientData('test1', 'test');




})(current, previous);



//client-side



$j("#QuickSearchLimit").text(g_user.getClientData('test1'));



console.log(g_user.getClientData('test1'));


Any luck with this approach Jason?