Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

Help with onsubmit catalog client script

MR1
Tera Contributor

I have a multiple-choice type variable "resource_group" with four choices (A, B, C, D)

The script below should run for three B, C, and D except A. However, the script below runs on all four, and a request is not submitted.

 

 

function onSubmit() {

    /*** Pop this gem into your script! */
    if (g_scratchpad.isFormValid) {
        return true;
    }
    var actionName = g_form.getActionName();
    var business = g_form.getReference('resource_group_to_be_updated', getValue);
    return false; 

    function getValue(business) {
        if (business.manager.toString() == '') {
            alert('cannot submit');
			location.reload(true);
            return false;
			
        }
		g_scratchpad.isFormValid = true;
		g_form.submit(actionName);
    }
}

 

 

Thanks

 

 

5 REPLIES 5

sanket16
Giga Guru

Hi @MR1 ,

 

Instead of GetReference method ,use GlideAjax with a script include and try the below logic for submission.
https://www.servicenow.com/community/developer-forum/using-return-false-in-glide-ajax/m-p/2539749/hi...

Thanks