<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>question Re: Onsubmit script is not working with script in Developer forum</title>
    <link>https://www.servicenow.com/community/developer-forum/onsubmit-script-is-not-working-with-script/m-p/3268805#M1203593</link>
    <description>&lt;P&gt;&lt;a href="https://www.servicenow.com/community/user/viewprofilepage/user-id/453945"&gt;@is_12&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;this worked for me in onLoad catalog client script&lt;/P&gt;
&lt;P&gt;I hope I answered your question and you can enhance it further.&lt;/P&gt;
&lt;LI-CODE lang="javascript"&gt;function onLoad() {
		var element = this.document.getElementsByClassName('btn btn-primary btn-block text-overflow-ellipsis ng-binding ng-scope');
		element[0].style.display = 'none';
}&lt;/LI-CODE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="AnkurBawiskar_0-1747748977910.png"&gt;&lt;img src="https://www.servicenow.com/community/image/serverpage/image-id/443541i04B5A750EB6229A4/image-size/medium?v=v2&amp;amp;px=400" alt="AnkurBawiskar_0-1747748977910.png" title="AnkurBawiskar_0-1747748977910.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Output:&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="AnkurBawiskar_1-1747748998896.png"&gt;&lt;img src="https://www.servicenow.com/community/image/serverpage/image-id/443542i257B09DCE756DB6D/image-size/medium?v=v2&amp;amp;px=400" alt="AnkurBawiskar_1-1747748998896.png" title="AnkurBawiskar_1-1747748998896.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If my response helped please mark it correct and close the thread so that it benefits future readers.&lt;/P&gt;</description>
    <pubDate>Tue, 20 May 2025 13:50:12 GMT</pubDate>
    <dc:creator>Ankur Bawiskar</dc:creator>
    <dc:date>2025-05-20T13:50:12Z</dc:date>
    <item>
      <title>Onsubmit script is not working with script</title>
      <link>https://www.servicenow.com/community/developer-forum/onsubmit-script-is-not-working-with-script/m-p/3268323#M1203389</link>
      <description>&lt;P&gt;Hello Community !&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;function&lt;/SPAN&gt;&lt;SPAN&gt; onSubmit() {&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;&lt;SPAN&gt;if&lt;/SPAN&gt;&lt;SPAN&gt; (g_user.hasRole(&lt;/SPAN&gt;&lt;SPAN&gt;'sn_customerservice_agent'&lt;/SPAN&gt;&lt;SPAN&gt;)) {&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;&lt;SPAN&gt;var&lt;/SPAN&gt;&lt;SPAN&gt; ga = &lt;/SPAN&gt;&lt;SPAN&gt;new&lt;/SPAN&gt; &lt;SPAN&gt;GlideAjax&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;'catalogUtils'&lt;/SPAN&gt;&lt;SPAN&gt;);&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ga.addParam(&lt;/SPAN&gt;&lt;SPAN&gt;'sysparm_name'&lt;/SPAN&gt;&lt;SPAN&gt;, &lt;/SPAN&gt;&lt;SPAN&gt;'hasExistingRITM'&lt;/SPAN&gt;&lt;SPAN&gt;);&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ga.addParam(&lt;/SPAN&gt;&lt;SPAN&gt;'sysparm_account'&lt;/SPAN&gt;&lt;SPAN&gt;, g_form.getValue(&lt;/SPAN&gt;&lt;SPAN&gt;'account'&lt;/SPAN&gt;&lt;SPAN&gt;));&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ga.addParam(&lt;/SPAN&gt;&lt;SPAN&gt;'sysparm_userId'&lt;/SPAN&gt;&lt;SPAN&gt;, g_form.getValue(&lt;/SPAN&gt;&lt;SPAN&gt;'contact_name'&lt;/SPAN&gt;&lt;SPAN&gt;));&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ga.addParam(&lt;/SPAN&gt;&lt;SPAN&gt;'sysparm_catalogItem'&lt;/SPAN&gt;&lt;SPAN&gt;, g_form.getUniqueValue());&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ga.getXMLAnswer(setData);&lt;/SPAN&gt;&lt;/DIV&gt;&lt;BR /&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; }&lt;/SPAN&gt;&lt;/DIV&gt;&lt;BR /&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;&lt;SPAN&gt;function&lt;/SPAN&gt;&lt;SPAN&gt; setData(response) {&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;&lt;SPAN&gt;var&lt;/SPAN&gt;&lt;SPAN&gt; answer = response;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; alert(&lt;/SPAN&gt;&lt;SPAN&gt;'reponse'&lt;/SPAN&gt;&lt;SPAN&gt; + answer);&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;&lt;SPAN&gt;if&lt;/SPAN&gt;&lt;SPAN&gt; (answer == &lt;/SPAN&gt;&lt;SPAN&gt;'false'&lt;/SPAN&gt;&lt;SPAN&gt;) {&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; alert(getMessage(&lt;/SPAN&gt;&lt;SPAN&gt;'You are not allowed to order as there is an existing request for this customer'&lt;/SPAN&gt;&lt;SPAN&gt;));&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;return&lt;/SPAN&gt; &lt;SPAN&gt;false&lt;/SPAN&gt;&lt;SPAN&gt;;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; } &lt;/SPAN&gt;&lt;SPAN&gt;else&lt;/SPAN&gt;&lt;SPAN&gt; {&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; alert(&lt;/SPAN&gt;&lt;SPAN&gt;"else if alert"&lt;/SPAN&gt;&lt;SPAN&gt;);&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;&lt;SPAN&gt;return&lt;/SPAN&gt; &lt;SPAN&gt;true&lt;/SPAN&gt;&lt;SPAN&gt;;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; }&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;}&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;I'm getting the alert message but form is getting submitted.&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;Tried with getXMLWait(), it is getting supported&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;Thanks,&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Tue, 20 May 2025 08:28:30 GMT</pubDate>
      <guid>https://www.servicenow.com/community/developer-forum/onsubmit-script-is-not-working-with-script/m-p/3268323#M1203389</guid>
      <dc:creator>is_12</dc:creator>
      <dc:date>2025-05-20T08:28:30Z</dc:date>
    </item>
    <item>
      <title>Re: Onsubmit script is not working with script</title>
      <link>https://www.servicenow.com/community/developer-forum/onsubmit-script-is-not-working-with-script/m-p/3268327#M1203390</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;GlideAjax calls are run async, so the script is completed and the form is submitted before you get the answer back from the call. Switch your script to run as an onChange client script instead of the onSubmit one.&lt;/P&gt;</description>
      <pubDate>Tue, 20 May 2025 08:32:18 GMT</pubDate>
      <guid>https://www.servicenow.com/community/developer-forum/onsubmit-script-is-not-working-with-script/m-p/3268327#M1203390</guid>
      <dc:creator>OlaN</dc:creator>
      <dc:date>2025-05-20T08:32:18Z</dc:date>
    </item>
    <item>
      <title>Re: Onsubmit script is not working with script</title>
      <link>https://www.servicenow.com/community/developer-forum/onsubmit-script-is-not-working-with-script/m-p/3268338#M1203392</link>
      <description>&lt;P&gt;&lt;a href="https://www.servicenow.com/community/user/viewprofilepage/user-id/302071"&gt;@OlaN&lt;/a&gt;&amp;nbsp;in onchange, How to retrict the form submission&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 20 May 2025 08:39:03 GMT</pubDate>
      <guid>https://www.servicenow.com/community/developer-forum/onsubmit-script-is-not-working-with-script/m-p/3268338#M1203392</guid>
      <dc:creator>is_12</dc:creator>
      <dc:date>2025-05-20T08:39:03Z</dc:date>
    </item>
    <item>
      <title>Re: Onsubmit script is not working with script</title>
      <link>https://www.servicenow.com/community/developer-forum/onsubmit-script-is-not-working-with-script/m-p/3268347#M1203396</link>
      <description>&lt;P&gt;I'm guessing you are restricting the form based on that you have one (or more) mandatory field to fill in.&lt;/P&gt;
&lt;P&gt;For example the user selected.&lt;/P&gt;
&lt;P&gt;When changing the user, do the check with the script, and if the user is not allowed, empty the field, so another user must be selected.&lt;/P&gt;</description>
      <pubDate>Tue, 20 May 2025 08:45:22 GMT</pubDate>
      <guid>https://www.servicenow.com/community/developer-forum/onsubmit-script-is-not-working-with-script/m-p/3268347#M1203396</guid>
      <dc:creator>OlaN</dc:creator>
      <dc:date>2025-05-20T08:45:22Z</dc:date>
    </item>
    <item>
      <title>Re: Onsubmit script is not working with script</title>
      <link>https://www.servicenow.com/community/developer-forum/onsubmit-script-is-not-working-with-script/m-p/3268349#M1203398</link>
      <description>&lt;P&gt;&lt;a href="https://www.servicenow.com/community/user/viewprofilepage/user-id/453945"&gt;@is_12&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;you should use onChange client script and show error message for that field&lt;/P&gt;
&lt;P&gt;This will ensure user passes the validation and selects the correct info and then only form will get submitted.&lt;/P&gt;
&lt;P&gt;If my response helped please mark it correct and close the thread so that it benefits future readers.&lt;/P&gt;</description>
      <pubDate>Tue, 20 May 2025 08:46:53 GMT</pubDate>
      <guid>https://www.servicenow.com/community/developer-forum/onsubmit-script-is-not-working-with-script/m-p/3268349#M1203398</guid>
      <dc:creator>Ankur Bawiskar</dc:creator>
      <dc:date>2025-05-20T08:46:53Z</dc:date>
    </item>
    <item>
      <title>Re: Onsubmit script is not working with script</title>
      <link>https://www.servicenow.com/community/developer-forum/onsubmit-script-is-not-working-with-script/m-p/3268367#M1203403</link>
      <description>&lt;P&gt;&lt;a href="https://www.servicenow.com/community/user/viewprofilepage/user-id/453945"&gt;@is_12&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;you will require 2 onChange client scripts i.e. 1 for account and 1 for contact name&lt;/P&gt;
&lt;P&gt;both the client script will have similar scripts and will show error on respective field/variable when validation fails.&lt;/P&gt;
&lt;P&gt;If my response helped please mark it correct and close the thread so that it benefits future readers.&lt;/P&gt;</description>
      <pubDate>Tue, 20 May 2025 08:55:33 GMT</pubDate>
      <guid>https://www.servicenow.com/community/developer-forum/onsubmit-script-is-not-working-with-script/m-p/3268367#M1203403</guid>
      <dc:creator>Ankur Bawiskar</dc:creator>
      <dc:date>2025-05-20T08:55:33Z</dc:date>
    </item>
    <item>
      <title>Re: Onsubmit script is not working with script</title>
      <link>https://www.servicenow.com/community/developer-forum/onsubmit-script-is-not-working-with-script/m-p/3268373#M1203405</link>
      <description>&lt;P&gt;&lt;a href="https://www.servicenow.com/community/user/viewprofilepage/user-id/302071"&gt;@OlaN&lt;/a&gt;&amp;nbsp;&lt;a href="https://www.servicenow.com/community/user/viewprofilepage/user-id/265966"&gt;@Ankur Bawiskar&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Requirement is to&amp;nbsp;&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;when agent is ordering the item from configurable workspace then write a logic as follows.&lt;OL&gt;&lt;LI&gt;On change of primary contact, fetch the primary contact's account and then go to RITM table and check for the catalog item and the account fetched from primary contact. If there is an existing record then restrict the agent from ordering and also display the alert message "You are not allowed to order as there is an existing request for this customer"&lt;/LI&gt;&lt;/OL&gt;&lt;/LI&gt;&lt;/OL&gt;</description>
      <pubDate>Tue, 20 May 2025 08:57:06 GMT</pubDate>
      <guid>https://www.servicenow.com/community/developer-forum/onsubmit-script-is-not-working-with-script/m-p/3268373#M1203405</guid>
      <dc:creator>is_12</dc:creator>
      <dc:date>2025-05-20T08:57:06Z</dc:date>
    </item>
    <item>
      <title>Re: Onsubmit script is not working with script</title>
      <link>https://www.servicenow.com/community/developer-forum/onsubmit-script-is-not-working-with-script/m-p/3268380#M1203410</link>
      <description>&lt;P&gt;&lt;a href="https://www.servicenow.com/community/user/viewprofilepage/user-id/453945"&gt;@is_12&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I already suggested to use 2 onChange client scripts&lt;/P&gt;
&lt;P&gt;When you use onSubmit with GlideAjax, there are challenges that the form gets submitted by the time the ajax function returns the value.&lt;/P&gt;
&lt;P&gt;If my response helped please mark it correct and close the thread so that it benefits future readers.&lt;/P&gt;</description>
      <pubDate>Tue, 20 May 2025 08:59:56 GMT</pubDate>
      <guid>https://www.servicenow.com/community/developer-forum/onsubmit-script-is-not-working-with-script/m-p/3268380#M1203410</guid>
      <dc:creator>Ankur Bawiskar</dc:creator>
      <dc:date>2025-05-20T08:59:56Z</dc:date>
    </item>
    <item>
      <title>Re: Onsubmit script is not working with script</title>
      <link>https://www.servicenow.com/community/developer-forum/onsubmit-script-is-not-working-with-script/m-p/3268381#M1203411</link>
      <description>&lt;P&gt;&lt;a href="https://www.servicenow.com/community/user/viewprofilepage/user-id/302071"&gt;@OlaN&lt;/a&gt;&amp;nbsp;&lt;a href="https://www.servicenow.com/community/user/viewprofilepage/user-id/265966"&gt;@Ankur Bawiskar&lt;/a&gt;&amp;nbsp;after the alert message, agent should not be able to submit the form, if he click's as well it should be restricted.&lt;/P&gt;</description>
      <pubDate>Tue, 20 May 2025 09:00:09 GMT</pubDate>
      <guid>https://www.servicenow.com/community/developer-forum/onsubmit-script-is-not-working-with-script/m-p/3268381#M1203411</guid>
      <dc:creator>is_12</dc:creator>
      <dc:date>2025-05-20T09:00:09Z</dc:date>
    </item>
    <item>
      <title>Re: Onsubmit script is not working with script</title>
      <link>https://www.servicenow.com/community/developer-forum/onsubmit-script-is-not-working-with-script/m-p/3268382#M1203412</link>
      <description>&lt;P&gt;&lt;a href="https://www.servicenow.com/community/user/viewprofilepage/user-id/453945"&gt;@is_12&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Would you mind closing your earlier questions by marking appropriate response as correct?&lt;/P&gt;
&lt;P&gt;Members have invested their time and efforts in helping you.&lt;/P&gt;
&lt;P&gt;&lt;A href="https://www.servicenow.com/community/developer-forum/disabling-order-now-button-for-the-agent/td-p/3261386" target="_blank" rel="noopener"&gt; Disabling order now button for the agent&lt;/A&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 20 May 2025 09:00:22 GMT</pubDate>
      <guid>https://www.servicenow.com/community/developer-forum/onsubmit-script-is-not-working-with-script/m-p/3268382#M1203412</guid>
      <dc:creator>Ankur Bawiskar</dc:creator>
      <dc:date>2025-05-20T09:00:22Z</dc:date>
    </item>
    <item>
      <title>Re: Onsubmit script is not working with script</title>
      <link>https://www.servicenow.com/community/developer-forum/onsubmit-script-is-not-working-with-script/m-p/3268387#M1203416</link>
      <description>&lt;P&gt;&lt;a href="https://www.servicenow.com/community/user/viewprofilepage/user-id/265966"&gt;@Ankur Bawiskar&lt;/a&gt;&amp;nbsp;one is on the contact &amp;amp; other one you are telling on the account(account is a readonly field)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 20 May 2025 09:02:28 GMT</pubDate>
      <guid>https://www.servicenow.com/community/developer-forum/onsubmit-script-is-not-working-with-script/m-p/3268387#M1203416</guid>
      <dc:creator>is_12</dc:creator>
      <dc:date>2025-05-20T09:02:28Z</dc:date>
    </item>
    <item>
      <title>Re: Onsubmit script is not working with script</title>
      <link>https://www.servicenow.com/community/developer-forum/onsubmit-script-is-not-working-with-script/m-p/3268388#M1203417</link>
      <description>&lt;P&gt;&lt;a href="https://www.servicenow.com/community/user/viewprofilepage/user-id/453945"&gt;@is_12&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;if account is readonly then only 1 onChange client script i.e. on Contact should be sufficient&lt;/P&gt;
&lt;P&gt;If my response helped please mark it correct and close the thread so that it benefits future readers.&lt;/P&gt;</description>
      <pubDate>Tue, 20 May 2025 09:03:24 GMT</pubDate>
      <guid>https://www.servicenow.com/community/developer-forum/onsubmit-script-is-not-working-with-script/m-p/3268388#M1203417</guid>
      <dc:creator>Ankur Bawiskar</dc:creator>
      <dc:date>2025-05-20T09:03:24Z</dc:date>
    </item>
    <item>
      <title>Re: Onsubmit script is not working with script</title>
      <link>https://www.servicenow.com/community/developer-forum/onsubmit-script-is-not-working-with-script/m-p/3268396#M1203420</link>
      <description>&lt;P&gt;You should update the logic in a way that form gets submitted only if the response is true. You can use this code&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="javascript"&gt;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
    }
}
&lt;/LI-CODE&gt;</description>
      <pubDate>Tue, 20 May 2025 09:08:13 GMT</pubDate>
      <guid>https://www.servicenow.com/community/developer-forum/onsubmit-script-is-not-working-with-script/m-p/3268396#M1203420</guid>
      <dc:creator>palanikumar</dc:creator>
      <dc:date>2025-05-20T09:08:13Z</dc:date>
    </item>
    <item>
      <title>Re: Onsubmit script is not working with script</title>
      <link>https://www.servicenow.com/community/developer-forum/onsubmit-script-is-not-working-with-script/m-p/3268435#M1203441</link>
      <description>&lt;P&gt;&lt;a href="https://www.servicenow.com/community/user/viewprofilepage/user-id/453945"&gt;@is_12&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN class=""&gt;You're &lt;/SPAN&gt;&lt;SPAN class=""&gt;using &lt;/SPAN&gt;GlideAjax.getXMLAnswer()&lt;SPAN class=""&gt;, &lt;/SPAN&gt;&lt;SPAN class=""&gt;which &lt;/SPAN&gt;&lt;SPAN class=""&gt;is &lt;/SPAN&gt;&lt;STRONG&gt;&lt;SPAN class=""&gt;asynchronous&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;SPAN class=""&gt;. &lt;/SPAN&gt;&lt;SPAN class=""&gt;This &lt;/SPAN&gt;&lt;SPAN class=""&gt;means &lt;/SPAN&gt;&lt;SPAN class=""&gt;the &lt;/SPAN&gt;onSubmit() &lt;SPAN class=""&gt;function &lt;/SPAN&gt;&lt;SPAN class=""&gt;completes &lt;/SPAN&gt;&lt;SPAN class=""&gt;before &lt;/SPAN&gt;setData() &lt;SPAN class=""&gt;finishes — &lt;/SPAN&gt;&lt;SPAN class=""&gt;so &lt;/SPAN&gt;&lt;SPAN class=""&gt;the &lt;/SPAN&gt;&lt;SPAN class=""&gt;form &lt;/SPAN&gt;&lt;SPAN class=""&gt;submission &lt;/SPAN&gt;&lt;SPAN class=""&gt;proceeds &lt;/SPAN&gt;&lt;STRONG&gt;&lt;SPAN class=""&gt;before &lt;/SPAN&gt;&lt;SPAN class=""&gt;the &lt;/SPAN&gt;&lt;SPAN class=""&gt;validation &lt;/SPAN&gt;&lt;SPAN class=""&gt;result &lt;/SPAN&gt;&lt;SPAN class=""&gt;is &lt;/SPAN&gt;&lt;SPAN class=""&gt;received&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;SPAN class=""&gt;.&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class=""&gt;If &lt;/SPAN&gt;&lt;SPAN class=""&gt;your &lt;/SPAN&gt;&lt;SPAN class=""&gt;goal &lt;/SPAN&gt;&lt;SPAN class=""&gt;is &lt;/SPAN&gt;&lt;SPAN class=""&gt;to &lt;/SPAN&gt;&lt;STRONG&gt;&lt;SPAN class=""&gt;validate &lt;/SPAN&gt;&lt;SPAN class=""&gt;the &lt;/SPAN&gt;&lt;SPAN class=""&gt;combination &lt;/SPAN&gt;&lt;SPAN class=""&gt;of &lt;/SPAN&gt;account&lt;SPAN class=""&gt;, &lt;/SPAN&gt;contact_name&lt;SPAN class=""&gt;, &lt;/SPAN&gt;&lt;SPAN class=""&gt;and &lt;/SPAN&gt;&lt;SPAN class=""&gt;catalog &lt;/SPAN&gt;&lt;SPAN class=""&gt;item&lt;/SPAN&gt;&lt;/STRONG&gt; &lt;SPAN class=""&gt;whenever &lt;/SPAN&gt;&lt;SPAN class=""&gt;a &lt;/SPAN&gt;&lt;SPAN class=""&gt;specific &lt;/SPAN&gt;&lt;SPAN class=""&gt;field &lt;/SPAN&gt;&lt;SPAN class=""&gt;changes (&lt;/SPAN&gt;&lt;SPAN class=""&gt;e.&lt;/SPAN&gt;&lt;SPAN class=""&gt;g. &lt;/SPAN&gt;contact_name &lt;SPAN class=""&gt;or &lt;/SPAN&gt;account&lt;SPAN class=""&gt;), &lt;/SPAN&gt;&lt;SPAN class=""&gt;you &lt;/SPAN&gt;&lt;SPAN class=""&gt;can &lt;/SPAN&gt;&lt;SPAN class=""&gt;do &lt;/SPAN&gt;&lt;SPAN class=""&gt;this &lt;/SPAN&gt;&lt;SPAN class=""&gt;via &lt;/SPAN&gt;onChange&lt;SPAN class=""&gt;.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class=""&gt;Here’s &lt;/SPAN&gt;&lt;SPAN class=""&gt;how &lt;/SPAN&gt;&lt;SPAN class=""&gt;to &lt;/SPAN&gt;&lt;SPAN class=""&gt;convert &lt;/SPAN&gt;&lt;SPAN class=""&gt;your &lt;/SPAN&gt;&lt;SPAN class=""&gt;script &lt;/SPAN&gt;&lt;SPAN class=""&gt;to &lt;/SPAN&gt;&lt;SPAN class=""&gt;an &lt;/SPAN&gt;onChange &lt;SPAN class=""&gt;client &lt;/SPAN&gt;&lt;SPAN class=""&gt;script (&lt;/SPAN&gt;&lt;SPAN class=""&gt;example: &lt;/SPAN&gt;&lt;SPAN class=""&gt;triggered &lt;/SPAN&gt;&lt;SPAN class=""&gt;when &lt;/SPAN&gt;contact_name)&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;function onChange(control, oldValue, newValue, isLoading) {
    if (isLoading || newValue === '') {
        return;
    }

    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', newValue);  // since contact_name is triggering
        ga.addParam('sysparm_catalogItem', g_form.getUniqueValue());

        ga.getXMLAnswer(function(response) {
            if (response === 'false') {
                g_form.showFieldMsg('contact_name', getMessage('You are not allowed to order as there is an existing request for this customer'), 'error');
            }
        });
    }
}&lt;/LI-CODE&gt;&lt;P&gt;Please mark correct/helpful if this helps you!&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 20 May 2025 09:49:25 GMT</pubDate>
      <guid>https://www.servicenow.com/community/developer-forum/onsubmit-script-is-not-working-with-script/m-p/3268435#M1203441</guid>
      <dc:creator>sunil maddheshi</dc:creator>
      <dc:date>2025-05-20T09:49:25Z</dc:date>
    </item>
    <item>
      <title>Re: Onsubmit script is not working with script</title>
      <link>https://www.servicenow.com/community/developer-forum/onsubmit-script-is-not-working-with-script/m-p/3268647#M1203523</link>
      <description>&lt;P&gt;&lt;a href="https://www.servicenow.com/community/user/viewprofilepage/user-id/23358"&gt;@palanikumar&lt;/a&gt;&amp;nbsp;I need to disable the button order now button&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;</description>
      <pubDate>Tue, 20 May 2025 12:28:09 GMT</pubDate>
      <guid>https://www.servicenow.com/community/developer-forum/onsubmit-script-is-not-working-with-script/m-p/3268647#M1203523</guid>
      <dc:creator>is_12</dc:creator>
      <dc:date>2025-05-20T12:28:09Z</dc:date>
    </item>
    <item>
      <title>Re: Onsubmit script is not working with script</title>
      <link>https://www.servicenow.com/community/developer-forum/onsubmit-script-is-not-working-with-script/m-p/3268659#M1203529</link>
      <description>&lt;P&gt;Did you try this solution?&lt;/P&gt;
&lt;P&gt;&lt;A href="https://www.servicenow.com/community/developer-forum/how-can-i-hide-the-order-now-button-of-catalog-item-via-client/m-p/1848272" target="_blank"&gt;https://www.servicenow.com/community/developer-forum/how-can-i-hide-the-order-now-button-of-catalog-item-via-client/m-p/1848272&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 20 May 2025 12:34:15 GMT</pubDate>
      <guid>https://www.servicenow.com/community/developer-forum/onsubmit-script-is-not-working-with-script/m-p/3268659#M1203529</guid>
      <dc:creator>palanikumar</dc:creator>
      <dc:date>2025-05-20T12:34:15Z</dc:date>
    </item>
    <item>
      <title>Re: Onsubmit script is not working with script</title>
      <link>https://www.servicenow.com/community/developer-forum/onsubmit-script-is-not-working-with-script/m-p/3268663#M1203532</link>
      <description>&lt;P&gt;&lt;a href="https://www.servicenow.com/community/user/viewprofilepage/user-id/265966"&gt;@Ankur Bawiskar&lt;/a&gt;after showing the alert message, I need to disable the order now button&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks,&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 20 May 2025 12:36:14 GMT</pubDate>
      <guid>https://www.servicenow.com/community/developer-forum/onsubmit-script-is-not-working-with-script/m-p/3268663#M1203532</guid>
      <dc:creator>is_12</dc:creator>
      <dc:date>2025-05-20T12:36:14Z</dc:date>
    </item>
    <item>
      <title>Re: Onsubmit script is not working with script</title>
      <link>https://www.servicenow.com/community/developer-forum/onsubmit-script-is-not-working-with-script/m-p/3268676#M1203537</link>
      <description>&lt;P&gt;&lt;a href="https://www.servicenow.com/community/user/viewprofilepage/user-id/453945"&gt;@is_12&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Sorry but you can't disable the Order Now button without DOM manipulation which is not recommended practice.&lt;/P&gt;
&lt;P&gt;I hope your Architect or Tech Lead or the person who has assigned this story knows this very well what's best practice and as a Lead their job is to Consult and provide the best solution.&lt;/P&gt;
&lt;P&gt;If my response helped please mark it correct and close the thread so that it benefits future readers.&lt;/P&gt;</description>
      <pubDate>Tue, 20 May 2025 12:41:26 GMT</pubDate>
      <guid>https://www.servicenow.com/community/developer-forum/onsubmit-script-is-not-working-with-script/m-p/3268676#M1203537</guid>
      <dc:creator>Ankur Bawiskar</dc:creator>
      <dc:date>2025-05-20T12:41:26Z</dc:date>
    </item>
    <item>
      <title>Re: Onsubmit script is not working with script</title>
      <link>https://www.servicenow.com/community/developer-forum/onsubmit-script-is-not-working-with-script/m-p/3268719#M1203556</link>
      <description>&lt;P&gt;Try this, button will not disable but request can not be submitted for false&lt;/P&gt;&lt;P&gt;function onSubmit() {&lt;BR /&gt;if (g_scratchpad.isFormValid) {&lt;BR /&gt;return true;&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;var actionName = g_form.getActionName();&lt;/P&gt;&lt;P&gt;if (g_user.hasRole('sn_customerservice_agent')) {&lt;BR /&gt;var ga = new GlideAjax('catalogUtils');&lt;BR /&gt;ga.addParam('sysparm_name', 'hasExistingRITM');&lt;BR /&gt;ga.addParam('sysparm_account', g_form.getValue('account'));&lt;BR /&gt;ga.addParam('sysparm_userId', g_form.getValue('contact_name'));&lt;BR /&gt;ga.addParam('sysparm_catalogItem', g_form.getUniqueValue());&lt;/P&gt;&lt;P&gt;ga.getXMLAnswer(function(response) {&lt;BR /&gt;var answer = response;&lt;BR /&gt;alert('response: ' + answer);&lt;/P&gt;&lt;P&gt;if (answer == 'false') {&lt;BR /&gt;alert(getMessage('You are not allowed to order as there is an existing request for this customer'));&lt;BR /&gt;g_scratchpad.isFormValid = false;&lt;BR /&gt;} else {&lt;BR /&gt;g_scratchpad.isFormValid = true;&lt;BR /&gt;g_form.submit(actionName);&lt;BR /&gt;}&lt;BR /&gt;});&lt;/P&gt;&lt;P&gt;return false;&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;return true;&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 20 May 2025 12:59:35 GMT</pubDate>
      <guid>https://www.servicenow.com/community/developer-forum/onsubmit-script-is-not-working-with-script/m-p/3268719#M1203556</guid>
      <dc:creator>Muhammad Salar</dc:creator>
      <dc:date>2025-05-20T12:59:35Z</dc:date>
    </item>
    <item>
      <title>Re: Onsubmit script is not working with script</title>
      <link>https://www.servicenow.com/community/developer-forum/onsubmit-script-is-not-working-with-script/m-p/3268778#M1203581</link>
      <description>&lt;P&gt;&lt;a href="https://www.servicenow.com/community/user/viewprofilepage/user-id/265966"&gt;@Ankur Bawiskar&lt;/a&gt;okay, Can you help me with the DOM manipulation. Let's give a try&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 20 May 2025 13:27:09 GMT</pubDate>
      <guid>https://www.servicenow.com/community/developer-forum/onsubmit-script-is-not-working-with-script/m-p/3268778#M1203581</guid>
      <dc:creator>is_12</dc:creator>
      <dc:date>2025-05-20T13:27:09Z</dc:date>
    </item>
  </channel>
</rss>

