<?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: How to query RITM table using a catalog variable field and client script parameter? in ITSM forum</title>
    <link>https://www.servicenow.com/community/itsm-forum/how-to-query-ritm-table-using-a-catalog-variable-field-and/m-p/511843#M83622</link>
    <description>&lt;P&gt;Hi Andi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I think "variables.47c6ee9047a11110bfc57868f36d43b6&lt;STRONG&gt;I&lt;/STRONG&gt;" contains an extra character which is &lt;STRONG&gt;I &lt;/STRONG&gt;at the end.&lt;/P&gt;
&lt;P&gt;So try replacing&lt;/P&gt;
&lt;P&gt;gr&lt;SPAN class="token punctuation"&gt;.&lt;/SPAN&gt;&lt;SPAN class="token function"&gt;addQuery&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;(&lt;/SPAN&gt;&lt;SPAN class="token string"&gt;'variables.47c6ee9047a11110bfc57868f36d43b6I'&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;,&lt;/SPAN&gt;&lt;SPAN class="token keyword"&gt;this&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;.&lt;/SPAN&gt;&lt;SPAN class="token function"&gt;getParameter&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;(&lt;/SPAN&gt;&lt;SPAN class="token string"&gt;'sysparm_firstname'&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;)&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;)&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;,&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;With&lt;/P&gt;
&lt;P&gt;&lt;SPAN class="token punctuation"&gt;gr.&lt;SPAN class="token function"&gt;addQuery&lt;/SPAN&gt;(&lt;SPAN class="token string"&gt;'variables.47c6ee9047a11110bfc57868f36d43b6'&lt;/SPAN&gt;,&lt;SPAN class="token keyword"&gt;this&lt;/SPAN&gt;.&lt;SPAN class="token function"&gt;getParameter&lt;/SPAN&gt;(&lt;SPAN class="token string"&gt;'sysparm_firstname'&lt;/SPAN&gt;)),&lt;/SPAN&gt;&lt;/P&gt;</description>
    <pubDate>Thu, 25 Aug 2022 14:55:49 GMT</pubDate>
    <dc:creator>Muhammad Khan</dc:creator>
    <dc:date>2022-08-25T14:55:49Z</dc:date>
    <item>
      <title>How to query RITM table using a catalog variable field and client script parameter?</title>
      <link>https://www.servicenow.com/community/itsm-forum/how-to-query-ritm-table-using-a-catalog-variable-field-and/m-p/511842#M83621</link>
      <description>&lt;P&gt;Hello, I am trying to query with catalog item variables while gliding RITM table. My goal is to use script include to perform a query using the variable&amp;nbsp; - firstname and value retrieved from newValue (Client Script) in variable itself before being submitted as requested item. Therefore, an alert returns when&amp;nbsp; I change the field (firstname) with data that is already submitted. The issue is that it seems to not be working when I query the following way the RITM table for the variables.&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;The variables.sysid (retrieved from RITM table). I think the issue might be there, but could not really make sense of it.&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;Also, another option I thought would work is current.variables.firstname.&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE class="language-javascript"&gt;&lt;CODE&gt;var UserExists = Class.create();
UserExists.prototype = Object.extendsObject(AbstractAjaxProcessor, {

    checkUserExists: function() {
        //var user_id = this.getParameter('username'); //get the value from client script
        var gr = new GlideRecord('sc_req_item');
		
		gr.addQuery('variables.47c6ee9047a11110bfc57868f36d43b6I',this.getParameter('sysparm_firstname')),
       // 

        //gr.addQuery('variables.5fa6ae5047a11110bfc57868f36d4314=andihoxha', this.getParameter('sysparm_username'));
        // gr.addEncodedQuery('variables.5fa6ae5047a11110bfc57868f36d4314=andihoxha');

        //gr.addQuery()
        gr.query();
        if (gr.next()) {
            return true;

        } else {

            return false;
        }

    },

    type: 'UserExists'
});&lt;/CODE&gt;&lt;/PRE&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;
   }
    
    //Type appropriate comment here, and begin script below
    var ga = new GlideAjax('UserExists'); // Ajax call
    ga.addParam('sysparm_name', 'checkUserExists'); //method from sclipt include which is used to add parameters
    ga.addParam('sysparm_firstname', newValue);


    ga.getXML(callScriptInclude); //callback the Script include

    function callScriptInclude(response) {
        var answer = response.responseXML.documentElement.getAttribute("answer"); //response return from Script Include
		
        if (answer == 'true') {
			alert('123');
            
        } 
        
    }	
   //Type appropriate comment here, and begin script below
   
}&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 25 Aug 2022 14:32:08 GMT</pubDate>
      <guid>https://www.servicenow.com/community/itsm-forum/how-to-query-ritm-table-using-a-catalog-variable-field-and/m-p/511842#M83621</guid>
      <dc:creator>Community Alums</dc:creator>
      <dc:date>2022-08-25T14:32:08Z</dc:date>
    </item>
    <item>
      <title>Re: How to query RITM table using a catalog variable field and client script parameter?</title>
      <link>https://www.servicenow.com/community/itsm-forum/how-to-query-ritm-table-using-a-catalog-variable-field-and/m-p/511843#M83622</link>
      <description>&lt;P&gt;Hi Andi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I think "variables.47c6ee9047a11110bfc57868f36d43b6&lt;STRONG&gt;I&lt;/STRONG&gt;" contains an extra character which is &lt;STRONG&gt;I &lt;/STRONG&gt;at the end.&lt;/P&gt;
&lt;P&gt;So try replacing&lt;/P&gt;
&lt;P&gt;gr&lt;SPAN class="token punctuation"&gt;.&lt;/SPAN&gt;&lt;SPAN class="token function"&gt;addQuery&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;(&lt;/SPAN&gt;&lt;SPAN class="token string"&gt;'variables.47c6ee9047a11110bfc57868f36d43b6I'&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;,&lt;/SPAN&gt;&lt;SPAN class="token keyword"&gt;this&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;.&lt;/SPAN&gt;&lt;SPAN class="token function"&gt;getParameter&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;(&lt;/SPAN&gt;&lt;SPAN class="token string"&gt;'sysparm_firstname'&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;)&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;)&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;,&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;With&lt;/P&gt;
&lt;P&gt;&lt;SPAN class="token punctuation"&gt;gr.&lt;SPAN class="token function"&gt;addQuery&lt;/SPAN&gt;(&lt;SPAN class="token string"&gt;'variables.47c6ee9047a11110bfc57868f36d43b6'&lt;/SPAN&gt;,&lt;SPAN class="token keyword"&gt;this&lt;/SPAN&gt;.&lt;SPAN class="token function"&gt;getParameter&lt;/SPAN&gt;(&lt;SPAN class="token string"&gt;'sysparm_firstname'&lt;/SPAN&gt;)),&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 25 Aug 2022 14:55:49 GMT</pubDate>
      <guid>https://www.servicenow.com/community/itsm-forum/how-to-query-ritm-table-using-a-catalog-variable-field-and/m-p/511843#M83622</guid>
      <dc:creator>Muhammad Khan</dc:creator>
      <dc:date>2022-08-25T14:55:49Z</dc:date>
    </item>
    <item>
      <title>Re: How to query RITM table using a catalog variable field and client script parameter?</title>
      <link>https://www.servicenow.com/community/itsm-forum/how-to-query-ritm-table-using-a-catalog-variable-field-and/m-p/511844#M83623</link>
      <description>&lt;P&gt;Thank you, it appears this tiny thing made the whole annoying for nothing.&lt;/P&gt;</description>
      <pubDate>Thu, 25 Aug 2022 15:21:23 GMT</pubDate>
      <guid>https://www.servicenow.com/community/itsm-forum/how-to-query-ritm-table-using-a-catalog-variable-field-and/m-p/511844#M83623</guid>
      <dc:creator>Community Alums</dc:creator>
      <dc:date>2022-08-25T15:21:23Z</dc:date>
    </item>
  </channel>
</rss>

