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

AshishKM
Kilo Patron
Kilo Patron

Hi @MR1 ,

Are you sure that you shared correct onSubmit script, in this script only "business.manager" empty check applied which is not matched with problem/issue statement. 

 

Also, try not to use getValue as call back function name because, its used by system as pre-defined method for g_form object. 

 

 

-Thanks,
AshishKMishra


Please mark this response as correct and helpful if it helps you can mark more that one reply as accepted solution

MR1
Tera Contributor

Yes, I shared the correct script.

"resource_group_to_be_updated" is a reference variable and we have another variable called "resource_group".

Based on the resource_group value, this reference field is displayed. If the reference field value manager is empty then abort submission but it is aborting the submission for all values.

We want to run the above script based on the resource_group value

 

ok , seems like you didn't share complete information at first place. Follow the @Tai Vu , he is expert.

 


Please mark this response as correct and helpful if it helps you can mark more that one reply as accepted solution

Tai Vu
Kilo Patron
Kilo Patron

Hey @MR1 

I've replied in your previous post.

Catalog client Script - Abort the submission of item

 

Cheers,

Tai Vu