- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-11-2020 08:47 PM
Can someone explain what g_scratchpad._ajaxChecked do? I can't find any reference right now but I see lots of scripts using it.
Solved! Go to Solution.
- Labels:
-
Scripting and Coding

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-12-2020 01:07 AM
Hi,
As suggested above its just a variable that is used for g_scratchpad object. g_scratchpad passes value from Server to Client when client (form) requires information that is not avaiable on the form (fields of the form).
So, look for Business rule & search with filter Script | Contains | g_scratchpad._ajaxChecked
You will find an entry where a value will be used in combination as below
g_scratchpad._ajaxChecked = ....something
This then is used in Client script in format
g_scratchpad._ajaxChecked so as to get value from Server (Business rule) to Client.
For better understanding try the same search as suggested above for Business Rule & then Client script.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-11-2020 10:51 PM
Thanks but how about the ._ajaxChecked? What does it mean when it is true or false?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-11-2020 11:25 PM
Hi
Is this something custom? I am searching for this in my PDI, but cannot find it anywhere...
Let me know, where you can find this (as some example), please.
BR
Dirk
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-12-2020 12:50 AM
Here's a sample script that used the _.ajaxChecked with g_scratchpad:
Community Post Link: https://community.servicenow.com/community?id=community_question&sys_id=c2d2b0d6dbd510106064eeb5ca96...
function onSubmit() {
if (g_form.getValue('Attachments') != "true") {
getMessage("Please attach 'SLF Asia Device Control - Exemption Request Form'", function(msg1) {
alert(msg1);
});
return false;
}
else {
if (g_scratchpad._ajaxChecked) {
// We have run our Ajax Checks, so we can continue on
// and let our form submission continue
return true;
}
// use this line below if you want to store the specific action name
g_scratchpad._action = g_form.getActionName();
g_scratchpad._ajaxChecked = false;
// var cat_id = g_form.getUniqueValue();
// var cat_id = gel('sysparm_item_guid').value;
var cat_id = g_form.getParameter("sysparm_item_guid");
alert(cat_id);
var ga = new GlideAjax('AttachmentPdfValidationAjax');
ga.addParam('sysparm_name', 'validateAttachment');
ga.addParam('sysparm_my_id', cat_id);
ga.getXMLAnswer(function(answer) {
console.log('Inside XML Answer '+answer);
// I made this a simple check of a true/false result
// but you can change this to check whatever suits your business case
// and base it on what gets returned from your script include
if (answer == "false") {
// it didn't pass our checks, so alert the user and quit
console.log('Inside answer = false block');
alert("Please attach PDF format form");
return;
}
// it worked! now we can resubmit the form with the
// property in place to allow us to continue
// so once we resubmit, it will re-run this function but will return true
// at line 5 of this script
g_scratchpad._ajaxChecked = true;
console.log('ajax true');
if (typeof g_form.orderNow != 'undefined') {
// this is a catalog item
g_form.orderNow();
}
else {
//this will resubmit the form using the saved
//ui action that was originally clicked
g_form.submit(g_scratchpad._action);
}
});
// always return false if we get to this point
return false;
}
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-12-2020 01:07 AM
Hi,
As suggested above its just a variable that is used for g_scratchpad object. g_scratchpad passes value from Server to Client when client (form) requires information that is not avaiable on the form (fields of the form).
So, look for Business rule & search with filter Script | Contains | g_scratchpad._ajaxChecked
You will find an entry where a value will be used in combination as below
g_scratchpad._ajaxChecked = ....something
This then is used in Client script in format
g_scratchpad._ajaxChecked so as to get value from Server (Business rule) to Client.
For better understanding try the same search as suggested above for Business Rule & then Client script.