getXmlWait not working even with the alternative method on Multirow variable set

Varun Sharma
Tera Expert

Hi Experts, 

 

Kindly guide me with your expertise. 

i'm trying to add a validation to mutli row variable set , validation should run before submitting the Row. 

i've used the alternate provided by service now KB0783579.

But it's still not working, on g_form.getActionName() i'm getting action value as none. 

 

here is the code

function onSubmit() {

    var validationGa = new GlideAjax('testingRoom');
    validationGa.addParam('sysparm_name', 'ValidateRoomFullName');
    validationGa.addParam('sysparm_room_type', g_form.getValue('room_type'));
    validationGa.addParam('sysparm_room_access', g_form.getValue('room_access'));
    validationGa.addParam('sysparm_capacity', g_form.getValue('maximum_number_of_people'));
    validationGa.addParam('sysparm_display_equipment', g_form.getValue('display_equipment'));
    validationGa.addParam('sysparm_room_full_name', g_form.getValue('room_full_name'));
    validationGa.getXMLAnswer(validationMessage);

    return false;

    function validationMessage(response) {
        var errorString = response;
        g_form.showFieldMsg('room_full_name', errorString, 'error');
        if (errorString != null) {
            spModal.open({
                title: 'Room Full Name Error',
                message: errorString,
                buttons: [{
                    label: 'OK',
                    primary: true
                }]
            });
            return false;
        }
        var actionName = g_form.getActionName();  
		console.log(actionName) // this returns none
        g_scratchpad.isFormValid = true;
        g_form.submit(actionName);
    }

}

 

 

Kindly help me through. #ServicePortal #ITSM

1 ACCEPTED SOLUTION

Tai Vu
Kilo Patron
Kilo Patron

Hi @Varun Sharma 

You're missing return true to allow user to submit once your validation is passed.

Let's try my adjustment below.

function onSubmit() {

    /*** Pop this gem into your script! */
    if (g_scratchpad.isFormValid) {
        return true;
    }
	var actionName = g_form.getActionName();

    var validationGa = new GlideAjax('testingRoom');
    validationGa.addParam('sysparm_name', 'ValidateRoomFullName');
    validationGa.addParam('sysparm_room_type', g_form.getValue('room_type'));
    validationGa.addParam('sysparm_room_access', g_form.getValue('room_access'));
    validationGa.addParam('sysparm_capacity', g_form.getValue('maximum_number_of_people'));
    validationGa.addParam('sysparm_display_equipment', g_form.getValue('display_equipment'));
    validationGa.addParam('sysparm_room_full_name', g_form.getValue('room_full_name'));
    validationGa.getXMLAnswer(validationMessage);

    return false;

    function validationMessage(response) {
        var errorString = response;
        g_form.showFieldMsg('room_full_name', errorString, 'error');
        if (errorString != null) {
            spModal.open({
                title: 'Room Full Name Error',
                message: errorString,
                buttons: [{
                    label: 'OK',
                    primary: true
                }]
            });
            return false;
        }

        g_scratchpad.isFormValid = true;
        g_form.submit(actionName);
    }

}

 

Cheers,

Tai Vu

View solution in original post

7 REPLIES 7

Hi Brad, 

 

Thanks for quick response. 

I'm able to retrieve errorString and it works fine and checks all the validations , give back the pop up window. it's causing the issue only when i try to submit it , as it doesn't go through. 

 

When i try to put the actionName outside of the function , i get the function name "submit", So when i press the add button , but it still doesn't submit the Row. 

 

VarunSharma_1-1700721158354.png 

VarunSharma_2-1700721214938.png

 

this is the alert i get when i put the actionName before Ajax call.

 

Regards, 


Varun Sharma

Tai Vu
Kilo Patron
Kilo Patron

Hi @Varun Sharma 

You're missing return true to allow user to submit once your validation is passed.

Let's try my adjustment below.

function onSubmit() {

    /*** Pop this gem into your script! */
    if (g_scratchpad.isFormValid) {
        return true;
    }
	var actionName = g_form.getActionName();

    var validationGa = new GlideAjax('testingRoom');
    validationGa.addParam('sysparm_name', 'ValidateRoomFullName');
    validationGa.addParam('sysparm_room_type', g_form.getValue('room_type'));
    validationGa.addParam('sysparm_room_access', g_form.getValue('room_access'));
    validationGa.addParam('sysparm_capacity', g_form.getValue('maximum_number_of_people'));
    validationGa.addParam('sysparm_display_equipment', g_form.getValue('display_equipment'));
    validationGa.addParam('sysparm_room_full_name', g_form.getValue('room_full_name'));
    validationGa.getXMLAnswer(validationMessage);

    return false;

    function validationMessage(response) {
        var errorString = response;
        g_form.showFieldMsg('room_full_name', errorString, 'error');
        if (errorString != null) {
            spModal.open({
                title: 'Room Full Name Error',
                message: errorString,
                buttons: [{
                    label: 'OK',
                    primary: true
                }]
            });
            return false;
        }

        g_scratchpad.isFormValid = true;
        g_form.submit(actionName);
    }

}

 

Cheers,

Tai Vu

Hi Tai Vu, 

 

Thankyou so much. 

It worked. 

i was stuck on it from so many hours. 

 

You are the best. 

Thanks You.