in ADF course (Application Development Fundamentals (Zurich)), lab 4.2.2, two rules are used to pass some data from server side to client side with g_scratchpad.
1. A "display" business rule, setting proerties to g_scratchpad
2. A client script, getting proerties from g_scratchpad and display a field in form
I strictly follow the guide in the course, except the "location_to_be_used" is replaced by me with "location_should_be_used" as the former one is not found, but this is not a matter.
When test above setting, I found client script get undefined values from g_scratchpad.
Then I make some debug:
1. Client script can display hard code value in "location_should_be_used" field.
2. Per some posts in community, in Client script side, I show content of g_scratchpad by getting keys with Object.keys(g_scratchpad), found only two keys/values in it,
browserSupported=true
isNewUI=true
there are no the properties set by business rule at all.
3. Per some posts in community, I rename the property in g_scratchpad with prefix 'u_', still not work
May I know what's the possible reason? Thanks.
below are details of the two rules, including my debug codes
business rules
code
(function executeRule(current, previous /*null when async*/) {
g_scratchpad.city = current.requested_for.city;
g_scratchpad.country = current.requested_for.country;
g_scratchpad.u_city = 'city222';
// Hooray for dotwalking!
// By writing these values to the scratchpad, a client script can easily fetch them.
})(current, previous);
client script

function onLoad() {
// This uses the dotwalking superpowers of the Scratchpad to use the requestor's city & state as the default location to be used. Make sure whomever you use for testing has values in their user record for this!
if (g_form.getValue('location_should_be_used') != '') {
return;
}
var city = g_scratchpad.city;
var country = g_scratchpad.country;
if (city && country) {
g_form.setValue('location_should_be_used', city + ', ' + country);
} else if (city) {
g_form.setValue('location_should_be_used', city);
} else if (country) {
g_form.setValue('location_should_be_used', country);
}
var u_city = g_scratchpad.u_city;
var items = Object.keys(g_scratchpad);
//g_form.setValue('location_should_be_used', 'country111aaa'+'-'+u_city+'--'+country); // this return undefine for u_city and country
g_form.setValue('location_should_be_used', 'items len='+items.length+'item[1]='+JSON.stringify(g_scratchpad[items[1]]));
if (city || country) {
g_form.showFieldMsg('location_should_be_used', 'Value set automatically - you may override by editing', 'info');
}
}