<?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: Setting variables read-only from a Client Script in Developer forum</title>
    <link>https://www.servicenow.com/community/developer-forum/setting-variables-read-only-from-a-client-script/m-p/1787554#M444480</link>
    <description>&lt;P&gt;Here's my solution.&lt;/P&gt;
&lt;P&gt;Create a Client Script (not Catalog Client Script) which runs on the Service Portal for the table sc_req_item:&lt;/P&gt;
&lt;PRE class="language-javascript"&gt;&lt;CODE&gt;function onLoad() {

	var $ = parent.$;

	function makeVariablesReadOnly() {
		var inputs = $('sp-variable-layout sp-variable-layout').find('input, textarea, select');
		for (var i=0; i&amp;lt;inputs.length; i++) {
			$(inputs[i]).attr('disabled', 'disabled');
		}
		setTimeout(makeVariablesReadOnly, 1000);
	}
	
	makeVariablesReadOnly();

}&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Advantage: Customization of Widgets not needed&lt;/P&gt;
&lt;P&gt;Disadvantage:&lt;/P&gt;
&lt;P&gt;- Uses undocumented parent-variable and jQuery&lt;/P&gt;
&lt;P&gt;- Runs every second&lt;/P&gt;</description>
    <pubDate>Tue, 30 Oct 2018 10:36:02 GMT</pubDate>
    <dc:creator>Fabian10</dc:creator>
    <dc:date>2018-10-30T10:36:02Z</dc:date>
    <item>
      <title>Setting variables read-only from a Client Script</title>
      <link>https://www.servicenow.com/community/developer-forum/setting-variables-read-only-from-a-client-script/m-p/1787542#M444468</link>
      <description>&lt;P&gt;Hi All,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;We have a sc_req_item Client Script that manages access to variables for the CMS user. It manages whether fields are read-only through variable attributes - allowing us to set read-only depending on the user's role, task state etc.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'm now trying to set up the sc_req_item on the Service Portal using the "Form Widget", which shows the fields, variable editor and the ticket conversation.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;But the Client Script isn't working on Service Portal. After investigating I've determined that variables aren't being populated in the g_form object so this doesn't do anything:&lt;/P&gt;&lt;P&gt;g_form.setReadOnly('variables.my_var_name', true);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Only the form &lt;STRONG&gt;fields&lt;/STRONG&gt; are being populated into g_form.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I've seen other posts that describe how to set all variables read-only by modifying the widget or creating Catalog Client Scripts presumably for every form.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;How can we create a script that will work across all Catalog Items to apply our desired variable behaviour?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;How can a Client Scripts access the variables or a Catalog Client Script access the fields? e.g. make all variables read-only when the task is closed?&lt;/P&gt;</description>
      <pubDate>Mon, 12 Feb 2018 11:41:51 GMT</pubDate>
      <guid>https://www.servicenow.com/community/developer-forum/setting-variables-read-only-from-a-client-script/m-p/1787542#M444468</guid>
      <dc:creator>tim2222</dc:creator>
      <dc:date>2018-02-12T11:41:51Z</dc:date>
    </item>
    <item>
      <title>Re: Setting variables read-only from a Client Script</title>
      <link>https://www.servicenow.com/community/developer-forum/setting-variables-read-only-from-a-client-script/m-p/1787543#M444469</link>
      <description>&lt;P&gt;Hi Tim,&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;Are you saying that your code is working for native and not working on service portal.&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;have onLoad catalog client script and have following code and check.&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;Also do you want to make the fields as read-only on catalog task form if it is closed?&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;if yes then following code should work on catalog item but not for catalog task:&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;if(g_form.getValue('state') == '&amp;lt;closed&amp;gt;'){&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&lt;SPAN style="color: #666666; font-family: arial, sans-serif;"&gt; g_form.setVariablesReadOnly(true);&lt;/SPAN&gt;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;}&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;Mark Correct if this solves your issue and also hit Like and Helpful if you find my response worthy based on the impact.&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;Ankur&lt;/P&gt;&lt;BR /&gt;</description>
      <pubDate>Mon, 12 Feb 2018 13:33:38 GMT</pubDate>
      <guid>https://www.servicenow.com/community/developer-forum/setting-variables-read-only-from-a-client-script/m-p/1787543#M444469</guid>
      <dc:creator>Ankur Bawiskar</dc:creator>
      <dc:date>2018-02-12T13:33:38Z</dc:date>
    </item>
    <item>
      <title>Re: Setting variables read-only from a Client Script</title>
      <link>https://www.servicenow.com/community/developer-forum/setting-variables-read-only-from-a-client-script/m-p/1787544#M444470</link>
      <description>&lt;P&gt;Hi Tim,&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;Be sure your client script is set to run on UI type All. It may be working in standard UI and CMS under Desktop, but to run in Service Portal, it need "mobile" capability also.&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="find_real_file.png"&gt;&lt;img src="https://www.servicenow.com/community/image/serverpage/image-id/204176i91DB9D700CB5D73B/image-size/large?v=v2&amp;amp;px=999" role="button" title="find_real_file.png" alt="find_real_file.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;BR /&gt;</description>
      <pubDate>Mon, 12 Feb 2018 13:44:41 GMT</pubDate>
      <guid>https://www.servicenow.com/community/developer-forum/setting-variables-read-only-from-a-client-script/m-p/1787544#M444470</guid>
      <dc:creator>Chuck Tomasi</dc:creator>
      <dc:date>2018-02-12T13:44:41Z</dc:date>
    </item>
    <item>
      <title>Re: Setting variables read-only from a Client Script</title>
      <link>https://www.servicenow.com/community/developer-forum/setting-variables-read-only-from-a-client-script/m-p/1787545#M444471</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;Thanks for your response.&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;I'm using the browser developer tools to debug the Client Script, so it is definitely being executed in the context of Service Portal.&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;When paused in the Client Script I can use the console to call g_form. From tracing the setReadOnly() call I can see the set of fields are only the &lt;STRONG&gt;fields&lt;/STRONG&gt;. A call to g_form from the client script can't set a variable read-only, if g_form is unaware of the variables.&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;So a client script can work on the fields, a catalog client script can work on the variables but neither can "see" the other?&lt;/P&gt;&lt;BR /&gt;</description>
      <pubDate>Mon, 12 Feb 2018 13:53:52 GMT</pubDate>
      <guid>https://www.servicenow.com/community/developer-forum/setting-variables-read-only-from-a-client-script/m-p/1787545#M444471</guid>
      <dc:creator>tim2222</dc:creator>
      <dc:date>2018-02-12T13:53:52Z</dc:date>
    </item>
    <item>
      <title>Re: Setting variables read-only from a Client Script</title>
      <link>https://www.servicenow.com/community/developer-forum/setting-variables-read-only-from-a-client-script/m-p/1787546#M444472</link>
      <description>&lt;P&gt;Hi Tim,&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;You are essentially correct. Client scripts are for table fields, Catalog client scripts are for variables. They have no awareness of each other. Most client scripts do not anyway...&lt;/P&gt;&lt;BR /&gt;</description>
      <pubDate>Mon, 12 Feb 2018 14:02:36 GMT</pubDate>
      <guid>https://www.servicenow.com/community/developer-forum/setting-variables-read-only-from-a-client-script/m-p/1787546#M444472</guid>
      <dc:creator>Chuck Tomasi</dc:creator>
      <dc:date>2018-02-12T14:02:36Z</dc:date>
    </item>
    <item>
      <title>Re: Setting variables read-only from a Client Script</title>
      <link>https://www.servicenow.com/community/developer-forum/setting-variables-read-only-from-a-client-script/m-p/1787547#M444473</link>
      <description>&lt;P&gt;Yes, our script works in native (/CMS) and not in Service Portal.&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;We have a complex implementation that controls whether variables are read-only, driven by the scratch pad, attributes on the variables and the state of the record.&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;I've seen &lt;SPAN style="color: #666666; font-family: arial, sans-serif;"&gt;setVariablesReadOnly &lt;/SPAN&gt;mentioned before on the community. I've tried using this in an sc_req_item Client Script and a Catalog Client Script, in neither context is this function available on g_form? (Although it wouldn't do what we require anyway.)&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;I'm using the "Form Widget".&lt;/P&gt;&lt;BR /&gt;</description>
      <pubDate>Mon, 12 Feb 2018 14:04:03 GMT</pubDate>
      <guid>https://www.servicenow.com/community/developer-forum/setting-variables-read-only-from-a-client-script/m-p/1787547#M444473</guid>
      <dc:creator>tim2222</dc:creator>
      <dc:date>2018-02-12T14:04:03Z</dc:date>
    </item>
    <item>
      <title>Re: Setting variables read-only from a Client Script</title>
      <link>https://www.servicenow.com/community/developer-forum/setting-variables-read-only-from-a-client-script/m-p/1787548#M444474</link>
      <description>&lt;P&gt;Can you confirm that this:&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;if(...condition...){&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;g_form.setVariablesReadOnly(true);&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;}&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;Does not and will not work on Service Portal (Jakarta)? I've seen this mentioned numerous times on community articles but there appears to be no API documentation and it does not seem to be implemented in the Service Portal version of g_form?&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;If no script exists in both the fields and variables spaces, how can we set variables to read only when a task is closed?&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;(It also seems the scratchpad is unavailable to Service Portal Catalog Client Scripts?)&lt;/P&gt;&lt;BR /&gt;</description>
      <pubDate>Mon, 12 Feb 2018 14:38:23 GMT</pubDate>
      <guid>https://www.servicenow.com/community/developer-forum/setting-variables-read-only-from-a-client-script/m-p/1787548#M444474</guid>
      <dc:creator>tim2222</dc:creator>
      <dc:date>2018-02-12T14:38:23Z</dc:date>
    </item>
    <item>
      <title>Re: Setting variables read-only from a Client Script</title>
      <link>https://www.servicenow.com/community/developer-forum/setting-variables-read-only-from-a-client-script/m-p/1787549#M444475</link>
      <description>&lt;P&gt;I can neither confirm nor deny it since it is not documented in our APIs.&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&lt;A href="https://developer.servicenow.com/app.do#!/api_doc?v=jakarta&amp;amp;id=c_GlideFormAPI" title="https://developer.servicenow.com/app.do#!/api_doc?v=jakarta&amp;amp;id=c_GlideFormAPI"&gt;https://developer.servicenow.com/app.do#!/api_doc?v=jakarta&amp;amp;id=c_GlideFormAPI&lt;/A&gt; &lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&lt;/P&gt;&lt;BR /&gt;&lt;P style="font-family: Times; color: #000000;"&gt;I recommend reaching out to customer support. I'll be interested to hear what they have to say.&lt;/P&gt;&lt;BR /&gt;&lt;P style="font-family: Times; color: #0000ee;"&gt;&lt;A href="https://hi.service-now.com/hisp"&gt;&lt;SPAN style="text-decoration: underline;"&gt;HI Service Portal - ServiceNow&lt;/SPAN&gt;&lt;/A&gt;&lt;/P&gt;&lt;BR /&gt;&lt;P style="font-family: Times; color: #0000ee;"&gt;&lt;A href="http://www.servicenow.com/support/contact-support.html"&gt;&lt;SPAN style="text-decoration: underline;"&gt;Contact Support | ServiceNow&lt;/SPAN&gt;&lt;/A&gt;&lt;/P&gt;&lt;BR /&gt;</description>
      <pubDate>Tue, 13 Feb 2018 12:19:31 GMT</pubDate>
      <guid>https://www.servicenow.com/community/developer-forum/setting-variables-read-only-from-a-client-script/m-p/1787549#M444475</guid>
      <dc:creator>Chuck Tomasi</dc:creator>
      <dc:date>2018-02-13T12:19:31Z</dc:date>
    </item>
    <item>
      <title>Re: Setting variables read-only from a Client Script</title>
      <link>https://www.servicenow.com/community/developer-forum/setting-variables-read-only-from-a-client-script/m-p/1787550#M444476</link>
      <description>&lt;P&gt;I believe I have a solution for our needs, which was prompted by this post:&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&lt;A title="Re: Interact with service portal widget in catalog item" __default_attr="996927" __jive_macro_name="message" class="jive_macro jive_macro_message" data-orig-content="Re: Interact with service portal widget in catalog item" data-renderedposition="31.5_8_348_16" href="https://www.servicenow.com/community?id=community_question&amp;amp;sys_id=5985c3eddbd8dbc01dcaf3231f96198d"&gt;Re: Interact with service portal widget in catalog item&lt;/A&gt;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;And that this callback in the Client Script for the Form widget:&lt;/P&gt;&lt;BR /&gt;&lt;PRE __default_attr="javascript" __jive_macro_name="code" class="jive_macro_code _jivemacro_uid_15185297680362143 jive_text_macro" data-renderedposition="92_8_1192_16" jivemacro_uid="_15185297680362143" modifiedtitle="true"&gt;&lt;P&gt;$scope.$on('spModel.gForm.initialized', function(e, gFormInstance) {&lt;/P&gt;&lt;BR /&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;Is also being called for the embedded variable editor. Provides a scriptable location that has access to both the form fields and variables.&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;To make use of this I've created a custom Form widget where I added a CustomEvent fire which provides both field and variable g_form objects to observers:&lt;/P&gt;&lt;BR /&gt;&lt;PRE __default_attr="javascript" __jive_macro_name="code" class="jive_macro_code _jivemacro_uid_15185299500743089 jive_text_macro" data-renderedposition="192_8_1192_144" jivemacro_uid="_15185299500743089" modifiedtitle="true"&gt;&lt;P&gt;var g_form;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;$scope.$on('spModel.gForm.initialized', function (e, gFormInstance) {&lt;/P&gt;&lt;BR /&gt;&lt;P&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; if (gFormInstance.getTableName() == $scope.data.f.table)&lt;/P&gt;&lt;BR /&gt;&lt;P&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; g_form = gFormInstance;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; // Trigger an event to indicate variables are ready&lt;/P&gt;&lt;BR /&gt;&lt;P&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; if (gFormInstance.getTableName() == null) { // Is there a better test for here?&lt;/P&gt;&lt;BR /&gt;&lt;P&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; CustomEvent.fire('soton.variable.ready', g_form, gFormInstance);&lt;/P&gt;&lt;BR /&gt;&lt;P&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;});&lt;/P&gt;&lt;BR /&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;Then in the sc_req_item Client Script I've added an observer that will apply our variable read-only policies (and as a Client Script also has access to g_scratchpad, which the variable editor doesn't):&lt;/P&gt;&lt;BR /&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;PRE __default_attr="javascript" __jive_macro_name="code" class="jive_macro_code _jivemacro_uid_15185299975319314 jive_text_macro" data-renderedposition="401_8_1192_16" jivemacro_uid="_15185299975319314" modifiedtitle="true"&gt;&lt;P&gt;CustomEvent.observe('soton.variable.ready', function(g_form, g_variable_form) {&lt;/P&gt;&lt;BR /&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;I can then perform operations over both the fields and variables e.g.&lt;/P&gt;&lt;BR /&gt;&lt;PRE __default_attr="javascript" __jive_macro_name="code" class="jive_macro_code jive_text_macro _jivemacro_uid_15185300060953889" data-renderedposition="459_8_1192_48" jivemacro_uid="_15185300060953889" modifiedtitle="true"&gt;&lt;P&gt;if (g_form.getValue('state') == -6) {&lt;/P&gt;&lt;BR /&gt;&lt;P&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; g_variable_form.setReadonly('comments', true);&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;}&lt;/P&gt;&lt;BR /&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;Note that g_variable_form - the g_form object on the variable editor - refers to variables using their name and does not expect a "variables." prefix.&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;In the many dead-ends I've gone down with this I've noticed that the Form widget and its g_form knows about variables but the Service Portal g_form class seems to be missing the equivalent functionality for handling variables that exists in Platform i.e. you can call a g_form function with "variables.{variable name}" and have it work on the variable.&lt;/P&gt;&lt;BR /&gt;</description>
      <pubDate>Tue, 13 Feb 2018 14:00:37 GMT</pubDate>
      <guid>https://www.servicenow.com/community/developer-forum/setting-variables-read-only-from-a-client-script/m-p/1787550#M444476</guid>
      <dc:creator>tim2222</dc:creator>
      <dc:date>2018-02-13T14:00:37Z</dc:date>
    </item>
    <item>
      <title>Re: Setting variables read-only from a Client Script</title>
      <link>https://www.servicenow.com/community/developer-forum/setting-variables-read-only-from-a-client-script/m-p/1787551#M444477</link>
      <description>&lt;P&gt;I have raised INT3608907 with 'hi' to clarify the API and to ask about missing support for variables in g_form.&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;To put this succinctly, on platform this works:&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;g_form.setReadonly('variables.foo', true);&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;But doesn't work on Service Portal. (On platform g_form has special handling for variables which is missing in the SP equivalent class, even though the variables data are available to the class.)&lt;/P&gt;&lt;BR /&gt;</description>
      <pubDate>Wed, 14 Feb 2018 08:43:34 GMT</pubDate>
      <guid>https://www.servicenow.com/community/developer-forum/setting-variables-read-only-from-a-client-script/m-p/1787551#M444477</guid>
      <dc:creator>tim2222</dc:creator>
      <dc:date>2018-02-14T08:43:34Z</dc:date>
    </item>
    <item>
      <title>Re: Setting variables read-only from a Client Script</title>
      <link>https://www.servicenow.com/community/developer-forum/setting-variables-read-only-from-a-client-script/m-p/1787552#M444478</link>
      <description>&lt;P&gt;Can you clarify why this doesn't work on the task (i.e. if the client script is also applied to the task)?&lt;/P&gt;</description>
      <pubDate>Thu, 01 Mar 2018 17:51:26 GMT</pubDate>
      <guid>https://www.servicenow.com/community/developer-forum/setting-variables-read-only-from-a-client-script/m-p/1787552#M444478</guid>
      <dc:creator>kkingsle</dc:creator>
      <dc:date>2018-03-01T17:51:26Z</dc:date>
    </item>
    <item>
      <title>Re: Setting variables read-only from a Client Script</title>
      <link>https://www.servicenow.com/community/developer-forum/setting-variables-read-only-from-a-client-script/m-p/1787553#M444479</link>
      <description>&lt;P&gt;Support have raised PRB1265323 to address this. A Client Script (not Catalog Client Script) is expected to be able to manipulate variables by using the "variables." prefix, which works on Platform but is not supported on Portal.&lt;/P&gt;</description>
      <pubDate>Wed, 11 Apr 2018 10:43:02 GMT</pubDate>
      <guid>https://www.servicenow.com/community/developer-forum/setting-variables-read-only-from-a-client-script/m-p/1787553#M444479</guid>
      <dc:creator>tim2222</dc:creator>
      <dc:date>2018-04-11T10:43:02Z</dc:date>
    </item>
    <item>
      <title>Re: Setting variables read-only from a Client Script</title>
      <link>https://www.servicenow.com/community/developer-forum/setting-variables-read-only-from-a-client-script/m-p/1787554#M444480</link>
      <description>&lt;P&gt;Here's my solution.&lt;/P&gt;
&lt;P&gt;Create a Client Script (not Catalog Client Script) which runs on the Service Portal for the table sc_req_item:&lt;/P&gt;
&lt;PRE class="language-javascript"&gt;&lt;CODE&gt;function onLoad() {

	var $ = parent.$;

	function makeVariablesReadOnly() {
		var inputs = $('sp-variable-layout sp-variable-layout').find('input, textarea, select');
		for (var i=0; i&amp;lt;inputs.length; i++) {
			$(inputs[i]).attr('disabled', 'disabled');
		}
		setTimeout(makeVariablesReadOnly, 1000);
	}
	
	makeVariablesReadOnly();

}&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Advantage: Customization of Widgets not needed&lt;/P&gt;
&lt;P&gt;Disadvantage:&lt;/P&gt;
&lt;P&gt;- Uses undocumented parent-variable and jQuery&lt;/P&gt;
&lt;P&gt;- Runs every second&lt;/P&gt;</description>
      <pubDate>Tue, 30 Oct 2018 10:36:02 GMT</pubDate>
      <guid>https://www.servicenow.com/community/developer-forum/setting-variables-read-only-from-a-client-script/m-p/1787554#M444480</guid>
      <dc:creator>Fabian10</dc:creator>
      <dc:date>2018-10-30T10:36:02Z</dc:date>
    </item>
    <item>
      <title>Re: Setting variables read-only from a Client Script</title>
      <link>https://www.servicenow.com/community/developer-forum/setting-variables-read-only-from-a-client-script/m-p/1787555#M444481</link>
      <description>&lt;P&gt;I have had to add "form-group" to the search to make it work for all fields (for me at least)&lt;/P&gt;
&lt;P&gt;I have embedded this into an onLoad and I am using this.document.readyState.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If the state is not complete I call this loop function again&lt;/P&gt;
&lt;P&gt;It if is complete, I will call the function that will do the work, but I have had to add a delay as it seems to trigger a little too quick (could be the client as their internet is a little slow at times)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 14 Feb 2019 11:59:50 GMT</pubDate>
      <guid>https://www.servicenow.com/community/developer-forum/setting-variables-read-only-from-a-client-script/m-p/1787555#M444481</guid>
      <dc:creator>poyntzj</dc:creator>
      <dc:date>2019-02-14T11:59:50Z</dc:date>
    </item>
    <item>
      <title>Re: Setting variables read-only from a Client Script</title>
      <link>https://www.servicenow.com/community/developer-forum/setting-variables-read-only-from-a-client-script/m-p/1787556#M444482</link>
      <description>&lt;P&gt;Thank you Fabian. Your solution worked great for me. I did make a minor tweak because I didn't want the script to run every second; I only needed it to execute at load. Sharing my very slightly tweaked version below:&lt;/P&gt;
&lt;PRE class="language-javascript"&gt;&lt;CODE&gt;function onLoad() {

	var $ = parent.$;

	function makeVariablesReadOnly() {
		var inputs = $('sp-variable-layout sp-variable-layout').find('input, textarea, select');
		for (var i=0; i&amp;lt;inputs.length; i++) {
			$(inputs[i]).attr('disabled', 'disabled');
		}		
	}	
	setTimeout(makeVariablesReadOnly, 1000);
}&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 20 Sep 2021 19:45:19 GMT</pubDate>
      <guid>https://www.servicenow.com/community/developer-forum/setting-variables-read-only-from-a-client-script/m-p/1787556#M444482</guid>
      <dc:creator>Tyler_Herman</dc:creator>
      <dc:date>2021-09-20T19:45:19Z</dc:date>
    </item>
  </channel>
</rss>

