@Ankur Bawiskarokay, Can you help me with the DOM manipulation. Let's give a try

 

Thanks

 

@is_12 

link shared by @palanikumar should help, you should enhance it as per your logic in catalog client script

Ensure you detect the correct HTML element

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  10x ServiceNow MVP  ||  ServiceNow Community Leader

@is_12 

this worked for me in onLoad catalog client script

I hope I answered your question and you can enhance it further.

function onLoad() {
		var element = this.document.getElementsByClassName('btn btn-primary btn-block text-overflow-ellipsis ng-binding ng-scope');
		element[0].style.display = 'none';
}

AnkurBawiskar_0-1747748977910.png

 

Output:

AnkurBawiskar_1-1747748998896.png

 

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  10x ServiceNow MVP  ||  ServiceNow Community Leader

View solution in original post

palanikumar
Giga Sage

You should update the logic in a way that form gets submitted only if the response is true. You can use this code

 

function onSubmit() {
    if (g_user.hasRole('sn_customerservice_agent')) {
        var ga = new GlideAjax('catalogUtils');
        ga.addParam('sysparm_name', 'hasExistingRITM');
        ga.addParam('sysparm_account', g_form.getValue('account'));
        ga.addParam('sysparm_userId', g_form.getValue('contact_name'));
        ga.addParam('sysparm_catalogItem', g_form.getUniqueValue());
        ga.getXMLAnswer(setData);
        return false; // Cancel the form submission
    }
}
function setData(response) {
    var answer = response;
    alert('reponse' + answer);
    if (answer == 'false') {
        alert(getMessage('You are not allowed to order as there is an existing request for this customer'));
    } else {
        alert("else if alert");
        g_form_submit(); // Submit the form only if the response is true
    }
}
Thank you,
Palani

@palanikumar I need to disable the button order now button

 

Thanks,