What does g_scratchpad._ajaxChecked do?

hanaphouse
Giga Guru

Can someone explain what g_scratchpad._ajaxChecked do? I can't find any reference right now but I see lots of scripts using it.

1 ACCEPTED SOLUTION

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.

View solution in original post

8 REPLIES 8

Thanks but how about the ._ajaxChecked? What does it mean when it is true or false?

DirkRedeker
Mega Sage

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

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;
    }
}

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.