<?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 Abort Form Submission in ITSM forum</title>
    <link>https://www.servicenow.com/community/itsm-forum/abort-form-submission/m-p/541451#M113230</link>
    <description>&lt;P class="root-block-node" data-changed="false" data-paragraphid="3"&gt;Hi all,&lt;/P&gt;
&lt;P class="root-block-node" data-changed="false" data-paragraphid="4"&gt;I have the below requirement.&lt;/P&gt;
&lt;P class="root-block-node" data-changed="false" data-paragraphid="5"&gt;In my catalog form, I have a variable called vendor(string). When the form is submitted, the information is saved in a custom table with the same column name (vendor).&lt;/P&gt;
&lt;P class="root-block-node" data-changed="false" data-paragraphid="6"&gt;So, if I enter any text in the variable vendor field, it should check the data in the custom table vendor field and prevent form submission if duplicate data is found.&lt;/P&gt;
&lt;P class="root-block-node" data-changed="true" data-paragraphid="7"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P class="root-block-node" data-changed="false" data-paragraphid="8"&gt;How could we achieve this?&lt;/P&gt;</description>
    <pubDate>Thu, 28 Jul 2022 18:11:45 GMT</pubDate>
    <dc:creator>Nag9</dc:creator>
    <dc:date>2022-07-28T18:11:45Z</dc:date>
    <item>
      <title>Abort Form Submission</title>
      <link>https://www.servicenow.com/community/itsm-forum/abort-form-submission/m-p/541451#M113230</link>
      <description>&lt;P class="root-block-node" data-changed="false" data-paragraphid="3"&gt;Hi all,&lt;/P&gt;
&lt;P class="root-block-node" data-changed="false" data-paragraphid="4"&gt;I have the below requirement.&lt;/P&gt;
&lt;P class="root-block-node" data-changed="false" data-paragraphid="5"&gt;In my catalog form, I have a variable called vendor(string). When the form is submitted, the information is saved in a custom table with the same column name (vendor).&lt;/P&gt;
&lt;P class="root-block-node" data-changed="false" data-paragraphid="6"&gt;So, if I enter any text in the variable vendor field, it should check the data in the custom table vendor field and prevent form submission if duplicate data is found.&lt;/P&gt;
&lt;P class="root-block-node" data-changed="true" data-paragraphid="7"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P class="root-block-node" data-changed="false" data-paragraphid="8"&gt;How could we achieve this?&lt;/P&gt;</description>
      <pubDate>Thu, 28 Jul 2022 18:11:45 GMT</pubDate>
      <guid>https://www.servicenow.com/community/itsm-forum/abort-form-submission/m-p/541451#M113230</guid>
      <dc:creator>Nag9</dc:creator>
      <dc:date>2022-07-28T18:11:45Z</dc:date>
    </item>
    <item>
      <title>Re: Abort Form Submission</title>
      <link>https://www.servicenow.com/community/itsm-forum/abort-form-submission/m-p/541452#M113231</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;Thanks for posting your requirement.&lt;/P&gt;
&lt;P&gt;What have you researched yourself? What do you think you need to do and where are you stuck?&lt;/P&gt;
&lt;P&gt;What have you tried? etc.&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;&lt;STRONG&gt;Please mark reply as Helpful, if applicable. Thanks!&lt;/STRONG&gt;&lt;/EM&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 28 Jul 2022 18:17:10 GMT</pubDate>
      <guid>https://www.servicenow.com/community/itsm-forum/abort-form-submission/m-p/541452#M113231</guid>
      <dc:creator>Allen Andreas</dc:creator>
      <dc:date>2022-07-28T18:17:10Z</dc:date>
    </item>
    <item>
      <title>Re: Abort Form Submission</title>
      <link>https://www.servicenow.com/community/itsm-forum/abort-form-submission/m-p/541453#M113232</link>
      <description>&lt;P&gt;Thanks allen for the qucik reply,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Wrote the script include and called that in on change client script, seems its not working&lt;/P&gt;
&lt;P&gt;Client script:&lt;/P&gt;
&lt;PRE class="language-javascript"&gt;&lt;CODE&gt;function onChange(control, oldValue, newValue, isLoading) {
   if (isLoading || newValue == '') {
      return;
   }

	var gaj = new GlideAjax('Vendor Checks'); 
	gaj.addParam('sysparm_name','Vendor');
	gaj.addParam('sysparm_field',newValue);
	gaj.getXML(ajaxResponse);
	function ajaxResponse(response) {
		var answer = response.responseXML.documentElement.getAttribute("answer");
		
		var values = answer.split(',');
		
		if (values.indexOf(newValue) != -1)
		  {
			alert("This value already exists");
		  }
					
		
	}&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Script include&lt;/P&gt;
&lt;PRE class="language-javascript"&gt;&lt;CODE&gt;Vendor : function()
	{
		var value = this.getParameter('sysparm_field');
		var answers =[];
		var gr = new GlideRecord('supplier_maintenance');
		gr.addQuery('u_vendor','vendor_data');
		gr.query();
		while(gr.next())
			{
				answers.push(gr.value.toString());
			}
		return answers.toString();

	},&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 29 Jul 2022 01:35:00 GMT</pubDate>
      <guid>https://www.servicenow.com/community/itsm-forum/abort-form-submission/m-p/541453#M113232</guid>
      <dc:creator>Nag9</dc:creator>
      <dc:date>2022-07-29T01:35:00Z</dc:date>
    </item>
    <item>
      <title>Re: Abort Form Submission</title>
      <link>https://www.servicenow.com/community/itsm-forum/abort-form-submission/m-p/541454#M113233</link>
      <description>&lt;P&gt;Hi are you getting the correct answer from Script Include? Can you place the alert in your client script and test like below&lt;/P&gt;
&lt;P&gt;function ajaxResponse(response) {&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; var answer = response.responseXML.documentElement.getAttribute("answer");&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; alert(answer);&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; var values = answer.split(',');&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; if (values.indexOf(newValue) != -1)&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; alert("This value already exists");&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;STRONG&gt; return false ; //abort submission you need this to abort submission&lt;/STRONG&gt;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; }&lt;/P&gt;</description>
      <pubDate>Fri, 29 Jul 2022 01:38:02 GMT</pubDate>
      <guid>https://www.servicenow.com/community/itsm-forum/abort-form-submission/m-p/541454#M113233</guid>
      <dc:creator>Harish KM</dc:creator>
      <dc:date>2022-07-29T01:38:02Z</dc:date>
    </item>
    <item>
      <title>Re: Abort Form Submission</title>
      <link>https://www.servicenow.com/community/itsm-forum/abort-form-submission/m-p/541455#M113234</link>
      <description>&lt;P&gt;Hey Nag,&lt;/P&gt;
&lt;P&gt;It looks like your Client Script is set to onChange when the check on whether we want abort the submission of an item should be done in an onSubmit catalog client script. You will need to either change your current script to onSubmit, or create a new client script that performs the check onSubmit.&lt;/P&gt;
&lt;P&gt;With that in mind, in your onSubmit catalog client script, simply add the following line of code to where you want to abort the submission.&lt;/P&gt;
&lt;PRE class="language-javascript"&gt;&lt;CODE&gt;return false;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;EM&gt;&lt;STRONG&gt;Please mark this answer correct or helpful if it solved your issue, thanks!&lt;/STRONG&gt;&lt;/EM&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 29 Jul 2022 02:13:24 GMT</pubDate>
      <guid>https://www.servicenow.com/community/itsm-forum/abort-form-submission/m-p/541455#M113234</guid>
      <dc:creator>Ethan Davies</dc:creator>
      <dc:date>2022-07-29T02:13:24Z</dc:date>
    </item>
    <item>
      <title>Re: Abort Form Submission</title>
      <link>https://www.servicenow.com/community/itsm-forum/abort-form-submission/m-p/541456#M113235</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;I'm glad you found my reply above &lt;STRONG&gt;Helpful&lt;/STRONG&gt;.&lt;/P&gt;
&lt;P&gt;For your script include and it not working, can you give more information about that? What have you tried thus far? What do your log entries say? What errors are you getting, etc.?&lt;/P&gt;
&lt;P&gt;Please provide more information as to what "not working" means.&lt;/P&gt;
&lt;P&gt;Additionally, in your script include, you're not using "value" which you're getting from the client script and you're also very close to using reserved words. I'd avoid using things like "value" or "answer(s)" when creating your own JavaScript variables.&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;&lt;STRONG&gt;Please mark reply as Helpful/Correct, if applicable. Thanks!&lt;/STRONG&gt;&lt;/EM&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 29 Jul 2022 13:26:55 GMT</pubDate>
      <guid>https://www.servicenow.com/community/itsm-forum/abort-form-submission/m-p/541456#M113235</guid>
      <dc:creator>Allen Andreas</dc:creator>
      <dc:date>2022-07-29T13:26:55Z</dc:date>
    </item>
  </channel>
</rss>

