<?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: Prevent user from submitting new ticket if there is still an open ticket in HRSD forum</title>
    <link>https://www.servicenow.com/community/hrsd-forum/prevent-user-from-submitting-new-ticket-if-there-is-still-an/m-p/1326303#M18285</link>
    <description>&lt;P&gt;Hi Filipe&lt;/P&gt;
&lt;P&gt;because I'm not so good at scripting, can you provide me an example &lt;STRONG&gt;Catalog client script that performs an Ajax call to the server to see if there is an already one hr case opened&lt;/STRONG&gt; please?&lt;/P&gt;
&lt;P&gt;The script to abort submit and display error I know how to do &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;Many thanks!&lt;/P&gt;</description>
    <pubDate>Fri, 22 Apr 2022 07:20:05 GMT</pubDate>
    <dc:creator>Charlotte</dc:creator>
    <dc:date>2022-04-22T07:20:05Z</dc:date>
    <item>
      <title>Prevent user from submitting new ticket if there is still an open ticket</title>
      <link>https://www.servicenow.com/community/hrsd-forum/prevent-user-from-submitting-new-ticket-if-there-is-still-an/m-p/1326301#M18283</link>
      <description>&lt;P&gt;How can I prevent a user from submitting a new HR Case via&amp;nbsp;record producer "Request move", if there is still an open HR Case for "Request move" for this user? So only 1 open HR Case per user for a specific HR Service can be possible.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks in advance!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 21 Apr 2022 12:01:22 GMT</pubDate>
      <guid>https://www.servicenow.com/community/hrsd-forum/prevent-user-from-submitting-new-ticket-if-there-is-still-an/m-p/1326301#M18283</guid>
      <dc:creator>Charlotte</dc:creator>
      <dc:date>2022-04-21T12:01:22Z</dc:date>
    </item>
    <item>
      <title>Re: Prevent user from submitting new ticket if there is still an open ticket</title>
      <link>https://www.servicenow.com/community/hrsd-forum/prevent-user-from-submitting-new-ticket-if-there-is-still-an/m-p/1326302#M18284</link>
      <description>&lt;P&gt;Hello Charlotte,&lt;BR /&gt;&lt;BR /&gt;Create an onSubmit Catalog client script that performs an Ajax call to the server to see if there is already one hr case opened. If so, abort the submit and display an error message stating that there is one hr case opened for that user.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;P&gt;Please, &lt;STRONG&gt;don't forget to mark my answer as correct&lt;/STRONG&gt; if it solves your issue or mark it as helpful if it is relevant for you!&lt;/P&gt;
&lt;P&gt;Best Regards,&lt;/P&gt;
&lt;P&gt;Filipe Cruz&lt;/P&gt;</description>
      <pubDate>Thu, 21 Apr 2022 12:27:16 GMT</pubDate>
      <guid>https://www.servicenow.com/community/hrsd-forum/prevent-user-from-submitting-new-ticket-if-there-is-still-an/m-p/1326302#M18284</guid>
      <dc:creator>Filipe Cruz</dc:creator>
      <dc:date>2022-04-21T12:27:16Z</dc:date>
    </item>
    <item>
      <title>Re: Prevent user from submitting new ticket if there is still an open ticket</title>
      <link>https://www.servicenow.com/community/hrsd-forum/prevent-user-from-submitting-new-ticket-if-there-is-still-an/m-p/1326303#M18285</link>
      <description>&lt;P&gt;Hi Filipe&lt;/P&gt;
&lt;P&gt;because I'm not so good at scripting, can you provide me an example &lt;STRONG&gt;Catalog client script that performs an Ajax call to the server to see if there is an already one hr case opened&lt;/STRONG&gt; please?&lt;/P&gt;
&lt;P&gt;The script to abort submit and display error I know how to do &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;Many thanks!&lt;/P&gt;</description>
      <pubDate>Fri, 22 Apr 2022 07:20:05 GMT</pubDate>
      <guid>https://www.servicenow.com/community/hrsd-forum/prevent-user-from-submitting-new-ticket-if-there-is-still-an/m-p/1326303#M18285</guid>
      <dc:creator>Charlotte</dc:creator>
      <dc:date>2022-04-22T07:20:05Z</dc:date>
    </item>
    <item>
      <title>Re: Prevent user from submitting new ticket if there is still an open ticket</title>
      <link>https://www.servicenow.com/community/hrsd-forum/prevent-user-from-submitting-new-ticket-if-there-is-still-an/m-p/1326304#M18286</link>
      <description>&lt;P&gt;Hi Charlotte,&lt;BR /&gt;&lt;BR /&gt;Here is an example of a Client script: (in this case is an onChange, but you want to do this in an onSubmit Client script).&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;PRE class="language-javascript"&gt;&lt;CODE&gt;function onChange(control, oldValue, newValue, isLoading, isTemplate) {
    if (isLoading) {
        return;
    }

    var test = g_form.getValue('enter your reference field');
    var check = new GlideAjax('your script include name');
    check.addParam('sysparm_name', 'script include function name');
    check.addParam('sysparm_comp', test);
    check.getXML(analyzeResponse);

    function analyzeResponse(response) {
        var answer = response.responseXML.documentElement.getAttribute("answer");
        alert(answer);
    }
}&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Please notice that the GlideAjax is calling a specific script include, the sysparm_name parameter will contain the method name in that script include, and sysparm_comp is one parameter to pass.&lt;BR /&gt;&lt;BR /&gt;Then your script include should look like this: (Must be checked as&amp;nbsp;&lt;STRONG&gt;client&lt;/STRONG&gt; callable, otherwise it will not work!)&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;PRE class="language-javascript"&gt;&lt;CODE&gt;var test = Class.create();
auto_fill_lochypcomp.prototype = Object.extendsObject(AbstractAjaxProcessor, {

    test: function() {
        var test = this.getParameter('sysparm_comp');
        var grp = new GlideRecord('sys_user');
        grp.addQuery('name', test);
        grp.query();
        while (grp.next()) {
            //now you can perform your query here.
        }
    },

    type: 'test'
});&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;&lt;BR /&gt;IF you want more details, please&amp;nbsp;refer to the following Servicenow Product Documentation link:&lt;BR /&gt;&lt;BR /&gt;&lt;A href="https://docs.servicenow.com/en-US/bundle/sandiego-application-development/page/script/ajax/topic/p_AJAX.html"&gt;https://docs.servicenow.com/en-US/bundle/sandiego-application-development/page/script/ajax/topic/p_AJAX.html&lt;BR /&gt;&lt;BR /&gt;&lt;/A&gt;Hope this helps you!!&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;P&gt;Please, &lt;STRONG&gt;don't forget to mark my answer as correct&lt;/STRONG&gt; if it solves your issue or mark it as helpful if it is relevant for you!&lt;/P&gt;
&lt;P&gt;Best Regards,&lt;/P&gt;
&lt;P&gt;Filipe Cruz&lt;/P&gt;</description>
      <pubDate>Fri, 22 Apr 2022 08:14:33 GMT</pubDate>
      <guid>https://www.servicenow.com/community/hrsd-forum/prevent-user-from-submitting-new-ticket-if-there-is-still-an/m-p/1326304#M18286</guid>
      <dc:creator>Filipe Cruz</dc:creator>
      <dc:date>2022-04-22T08:14:33Z</dc:date>
    </item>
    <item>
      <title>Re: Prevent user from submitting new ticket if there is still an open ticket</title>
      <link>https://www.servicenow.com/community/hrsd-forum/prevent-user-from-submitting-new-ticket-if-there-is-still-an/m-p/1326305#M18287</link>
      <description>&lt;P&gt;Hi Filipe&lt;/P&gt;
&lt;P&gt;thanks again for your advice. Can this also be an "onLoad" client script?&lt;/P&gt;
&lt;P&gt;Because we don't want the employee doing all the effort of filing in a form, to see "onSubmit" that he can't submit the ticket &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 27 Apr 2022 06:32:58 GMT</pubDate>
      <guid>https://www.servicenow.com/community/hrsd-forum/prevent-user-from-submitting-new-ticket-if-there-is-still-an/m-p/1326305#M18287</guid>
      <dc:creator>Charlotte</dc:creator>
      <dc:date>2022-04-27T06:32:58Z</dc:date>
    </item>
    <item>
      <title>Re: Prevent user from submitting new ticket if there is still an open ticket</title>
      <link>https://www.servicenow.com/community/hrsd-forum/prevent-user-from-submitting-new-ticket-if-there-is-still-an/m-p/1326306#M18288</link>
      <description>&lt;P&gt;Hi Charlotte,&lt;BR /&gt;&lt;BR /&gt;Sure!! You can perform that validation right at the beginning, when the form is loaded! You can present some kind of message to the user to inform that there is already a "Request move" case open.&lt;BR /&gt;&lt;BR /&gt;Also keep the onSubmit client script active since you might have users trying to submit that second case (and you want to avoid that case from being created).&lt;BR /&gt;&lt;BR /&gt;Hope this helps!&lt;BR /&gt;&lt;BR /&gt;Let me know if you need further assistance on this topic!!&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;P&gt;Please, &lt;STRONG&gt;don't forget to mark my answer as correct&lt;/STRONG&gt; if it solves your issue or mark it as helpful if it is relevant for you!&lt;/P&gt;
&lt;P&gt;Best Regards,&lt;/P&gt;
&lt;P&gt;Filipe Cruz&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 27 Apr 2022 08:15:24 GMT</pubDate>
      <guid>https://www.servicenow.com/community/hrsd-forum/prevent-user-from-submitting-new-ticket-if-there-is-still-an/m-p/1326306#M18288</guid>
      <dc:creator>Filipe Cruz</dc:creator>
      <dc:date>2022-04-27T08:15:24Z</dc:date>
    </item>
  </channel>
</rss>

