<?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 Is it possible to make a field mandatory and read only in the form ? If yes what is the use ? in Developer forum</title>
    <link>https://www.servicenow.com/community/developer-forum/is-it-possible-to-make-a-field-mandatory-and-read-only-in-the/m-p/1929591#M586517</link>
    <description>&lt;P&gt;Is it possible to make a field mandatory and read only in the form ? If yes what is the use ?&lt;/P&gt;</description>
    <pubDate>Mon, 15 Jul 2019 10:01:27 GMT</pubDate>
    <dc:creator>Karunakar3</dc:creator>
    <dc:date>2019-07-15T10:01:27Z</dc:date>
    <item>
      <title>Is it possible to make a field mandatory and read only in the form ? If yes what is the use ?</title>
      <link>https://www.servicenow.com/community/developer-forum/is-it-possible-to-make-a-field-mandatory-and-read-only-in-the/m-p/1929591#M586517</link>
      <description>&lt;P&gt;Is it possible to make a field mandatory and read only in the form ? If yes what is the use ?&lt;/P&gt;</description>
      <pubDate>Mon, 15 Jul 2019 10:01:27 GMT</pubDate>
      <guid>https://www.servicenow.com/community/developer-forum/is-it-possible-to-make-a-field-mandatory-and-read-only-in-the/m-p/1929591#M586517</guid>
      <dc:creator>Karunakar3</dc:creator>
      <dc:date>2019-07-15T10:01:27Z</dc:date>
    </item>
    <item>
      <title>Re: Is it possible to make a field mandatory and read only in the form ? If yes what is the use ?</title>
      <link>https://www.servicenow.com/community/developer-forum/is-it-possible-to-make-a-field-mandatory-and-read-only-in-the/m-p/1929592#M586518</link>
      <description>&lt;P&gt;Hi Karunakar,&lt;/P&gt;
&lt;P&gt;You can of course set a field to both Read-Only and Mandatory, however the Read-Only part will "win-out" against it. Meaning, even if there isn't a value in the field, you could still save the record. Just like Mandatory will win out over Visible.&lt;/P&gt;
&lt;P&gt;I would rarely recommend using the checkboxes on the Dictionary Entry to set Read-Only and Mandatory, instead I'd recommend using a UI Policy.&lt;/P&gt;
&lt;P&gt;I think there are very few use cases for making something Read-Only and Mandatory. One I can think of is if you want to ensure a field is always Mandatory, and there are cases that would change whether or not it is Read Only, but even then, I would think you could have the Mandatory set to true/false with the&amp;nbsp;opposite of the same condition as the Read Only being set to true/false.&lt;/P&gt;
&lt;P&gt;Is there a specific use-case you had in mind, or did you just want some thoughts on this? Let me know if I can assist further.&amp;nbsp;&lt;/P&gt;
&lt;P class="ng-scope"&gt;&lt;STRONG&gt;If my answer was helpful or answered your question, please mark it as 'Helpful' or 'Correct'&lt;/STRONG&gt;&lt;/P&gt;
&lt;P class="ng-scope"&gt;Thanks!&lt;/P&gt;
&lt;P class="ng-scope"&gt;Josh&lt;/P&gt;</description>
      <pubDate>Mon, 15 Jul 2019 21:09:48 GMT</pubDate>
      <guid>https://www.servicenow.com/community/developer-forum/is-it-possible-to-make-a-field-mandatory-and-read-only-in-the/m-p/1929592#M586518</guid>
      <dc:creator>Josh Virelli</dc:creator>
      <dc:date>2019-07-15T21:09:48Z</dc:date>
    </item>
    <item>
      <title>Re: Is it possible to make a field mandatory and read only in the form ? If yes what is the use ?</title>
      <link>https://www.servicenow.com/community/developer-forum/is-it-possible-to-make-a-field-mandatory-and-read-only-in-the/m-p/1929593#M586519</link>
      <description>&lt;P&gt;Hello Karunakar,&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Client Script:&lt;/STRONG&gt;&lt;/P&gt;
&lt;P class="shortdesc"&gt;Client scripts allow the system to run JavaScript on the client (web browser) when client-based events occur, such as when a form loads, after form submission, or when a field changes value.&lt;/P&gt;
Use client scripts to configure forms, form fields, and field values while the user is using the form. Client scripts can:
&lt;UL id="client-scripts__ul_zp5_n5y_vdb" class="ul"&gt;&lt;LI class="li"&gt;make fields hidden or visible&lt;/LI&gt;&lt;LI class="li"&gt;make fields read only or writable&lt;/LI&gt;&lt;LI class="li"&gt;make fields optional or mandatory based on the user's role&lt;/LI&gt;&lt;LI class="li"&gt;set the value in one field based on the value in other fields&lt;/LI&gt;&lt;LI class="li"&gt;modify the options in a choice list based on a user's role&lt;/LI&gt;&lt;LI class="li"&gt;display messages based on a value in a field&lt;/LI&gt;&lt;/UL&gt;
&lt;P&gt;&lt;STRONG&gt;UI POLICIES:&lt;/STRONG&gt;&lt;/P&gt;
&lt;P class="shortdesc"&gt;UI policies dynamically change the behavior of information on a form and control custom process flows for tasks.&lt;/P&gt;

&lt;P class="p"&gt;For example, you can use UI policies to make the number field on a form read-only, make the short description field mandatory, and hide other fields. Basic UI policies do not require any scripting, however for more advanced actions, use the&amp;nbsp;&lt;SPAN class="ph uicontrol"&gt;Run scripts&lt;/SPAN&gt;option.&lt;/P&gt;
&lt;P class="p"&gt;You can also use client scripts to perform all of these actions, but for faster load times use UI policies when possible&lt;/P&gt;
&lt;P class="p"&gt;&lt;STRONG&gt;Please mark as Correct Answer/Helpful, if applicable.&lt;/STRONG&gt;&lt;BR /&gt;Thanks! &lt;BR /&gt;Abhishek Gardade&lt;/P&gt;
&lt;P class="p"&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 16 Jul 2019 06:09:43 GMT</pubDate>
      <guid>https://www.servicenow.com/community/developer-forum/is-it-possible-to-make-a-field-mandatory-and-read-only-in-the/m-p/1929593#M586519</guid>
      <dc:creator>AbhishekGardade</dc:creator>
      <dc:date>2019-07-16T06:09:43Z</dc:date>
    </item>
    <item>
      <title>Re: Is it possible to make a field mandatory and read only in the form ? If yes what is the use ?</title>
      <link>https://www.servicenow.com/community/developer-forum/is-it-possible-to-make-a-field-mandatory-and-read-only-in-the/m-p/1929594#M586520</link>
      <description>&lt;P&gt;Hi Josh,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks for the quick reply,&amp;nbsp; I need some scenarios where will we use mandatory and read only for a field in the form ??&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks in Advance&lt;/P&gt;</description>
      <pubDate>Tue, 16 Jul 2019 06:44:59 GMT</pubDate>
      <guid>https://www.servicenow.com/community/developer-forum/is-it-possible-to-make-a-field-mandatory-and-read-only-in-the/m-p/1929594#M586520</guid>
      <dc:creator>Karunakar3</dc:creator>
      <dc:date>2019-07-16T06:44:59Z</dc:date>
    </item>
    <item>
      <title>Re: Is it possible to make a field mandatory and read only in the form ? If yes what is the use ?</title>
      <link>https://www.servicenow.com/community/developer-forum/is-it-possible-to-make-a-field-mandatory-and-read-only-in-the/m-p/1929595#M586521</link>
      <description>&lt;P&gt;Hi &lt;SN-MENTION class="sn-mention" table="live_profile" sysid="914f0ea5db181fc09c9ffb651f961937"&gt;@Josh Virelli - CloudPires&lt;/SN-MENTION&gt;&amp;nbsp;- I have a case where I need a field within an application to be Read Only, unless they have a certain role, to be Mandatory. Using a UI Policy, i have it working when I have 1 role listed, but I'm unsure on how to write it for the 2nd role (where I need it to be mandatory. Lets say role is 'test_mandatory')...you have suggestions?&lt;/P&gt;
&lt;P&gt;I've started with this:&lt;/P&gt;
&lt;P&gt;function onCondition() {&lt;BR /&gt;if(g_user.hasRoleExactly('test_read_only'))&lt;BR /&gt;g_form.setMandatory('name', false);&lt;BR /&gt;g_form.setReadOnly('name', true);&lt;BR /&gt;}&lt;/P&gt;</description>
      <pubDate>Wed, 30 Sep 2020 13:30:53 GMT</pubDate>
      <guid>https://www.servicenow.com/community/developer-forum/is-it-possible-to-make-a-field-mandatory-and-read-only-in-the/m-p/1929595#M586521</guid>
      <dc:creator>Mairvette Tuck1</dc:creator>
      <dc:date>2020-09-30T13:30:53Z</dc:date>
    </item>
    <item>
      <title>Re: Is it possible to make a field mandatory and read only in the form ? If yes what is the use ?</title>
      <link>https://www.servicenow.com/community/developer-forum/is-it-possible-to-make-a-field-mandatory-and-read-only-in-the/m-p/1929596#M586522</link>
      <description>&lt;P&gt;Just tested by setting a field Read-only and mandatory using UI policy. The result is the field is made mandatory and a value needs to be entered (that is, it's not read-only).&lt;/P&gt;
&lt;P&gt;UI Policy&lt;/P&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/48970i0D873DA4550A4381/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;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Try it page&lt;/P&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/48966i8F82717E10F74ABE/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;P&gt;Submit without entering value&lt;/P&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/48971i7BA8B2566161E1E5/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;</description>
      <pubDate>Wed, 30 Sep 2020 14:18:46 GMT</pubDate>
      <guid>https://www.servicenow.com/community/developer-forum/is-it-possible-to-make-a-field-mandatory-and-read-only-in-the/m-p/1929596#M586522</guid>
      <dc:creator>Hitoshi Ozawa</dc:creator>
      <dc:date>2020-09-30T14:18:46Z</dc:date>
    </item>
    <item>
      <title>Re: Is it possible to make a field mandatory and read only in the form ? If yes what is the use ?</title>
      <link>https://www.servicenow.com/community/developer-forum/is-it-possible-to-make-a-field-mandatory-and-read-only-in-the/m-p/1929597#M586523</link>
      <description>&lt;P&gt;Hey Mairvette,&lt;/P&gt;
&lt;P&gt;If I'm understanding correctly, I think you would just add an Else If condition for that second role&lt;/P&gt;
&lt;P&gt;function onCondition() {&lt;BR /&gt;if(g_user.hasRoleExactly('test_read_only')){&lt;BR /&gt;g_form.setMandatory('name', false);&lt;BR /&gt;g_form.setReadOnly('name', true);&lt;BR /&gt;}else if (g_user.hasRoleExactly('test_mandatory'){&lt;BR /&gt;g_form.setMandatory('name', true);&lt;BR /&gt;g_form.setReadOnly('name', false);&lt;BR /&gt;}&lt;BR /&gt;}&lt;/P&gt;
&lt;P&gt;Let me know if that helps!&lt;/P&gt;
&lt;P class="ng-scope"&gt;&lt;STRONG&gt;If my answer was helpful or answered your question, please mark it as 'Helpful' or 'Correct'&lt;/STRONG&gt;&lt;/P&gt;
&lt;P class="ng-scope"&gt;Thanks!&lt;/P&gt;
&lt;P class="ng-scope"&gt;Josh&lt;/P&gt;</description>
      <pubDate>Wed, 30 Sep 2020 14:24:05 GMT</pubDate>
      <guid>https://www.servicenow.com/community/developer-forum/is-it-possible-to-make-a-field-mandatory-and-read-only-in-the/m-p/1929597#M586523</guid>
      <dc:creator>Josh Virelli</dc:creator>
      <dc:date>2020-09-30T14:24:05Z</dc:date>
    </item>
    <item>
      <title>Re: Is it possible to make a field mandatory and read only in the form ? If yes what is the use ?</title>
      <link>https://www.servicenow.com/community/developer-forum/is-it-possible-to-make-a-field-mandatory-and-read-only-in-the/m-p/1929598#M586524</link>
      <description>&lt;P&gt;A case when Mandatory and Read-only is used is when requiring valid email address of a logged in user.&lt;/P&gt;
&lt;P&gt;A password reset form may have a field to enter logged in user in a user field and only fetch logged in user's email address. However, a new user or a part time user may not yet be assigned an email address. In this situation, since there's no valid email to send an email to reset the password, submission should fail and tell the user to wait.&lt;/P&gt;</description>
      <pubDate>Wed, 30 Sep 2020 14:34:44 GMT</pubDate>
      <guid>https://www.servicenow.com/community/developer-forum/is-it-possible-to-make-a-field-mandatory-and-read-only-in-the/m-p/1929598#M586524</guid>
      <dc:creator>Hitoshi Ozawa</dc:creator>
      <dc:date>2020-09-30T14:34:44Z</dc:date>
    </item>
    <item>
      <title>Re: Is it possible to make a field mandatory and read only in the form ? If yes what is the use ?</title>
      <link>https://www.servicenow.com/community/developer-forum/is-it-possible-to-make-a-field-mandatory-and-read-only-in-the/m-p/1929599#M586525</link>
      <description>&lt;P&gt;That works!! I had used the 'else' but my&amp;nbsp;braces were set differently.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you!!&lt;/P&gt;</description>
      <pubDate>Wed, 30 Sep 2020 15:50:05 GMT</pubDate>
      <guid>https://www.servicenow.com/community/developer-forum/is-it-possible-to-make-a-field-mandatory-and-read-only-in-the/m-p/1929599#M586525</guid>
      <dc:creator>Mairvette Tuck1</dc:creator>
      <dc:date>2020-09-30T15:50:05Z</dc:date>
    </item>
    <item>
      <title>Re: Is it possible to make a field mandatory and read only in the form ? If yes what is the use ?</title>
      <link>https://www.servicenow.com/community/developer-forum/is-it-possible-to-make-a-field-mandatory-and-read-only-in-the/m-p/1929600#M586526</link>
      <description>&lt;P&gt;That works!&lt;/P&gt;
&lt;P&gt;Another angle I was presented with was by default, users all having role 'test_read_only', and instead of the role being removed, adding the role 'test_mandatory' for specific users.&lt;/P&gt;
&lt;P&gt;Would that even be possible?&lt;/P&gt;</description>
      <pubDate>Wed, 30 Sep 2020 15:58:13 GMT</pubDate>
      <guid>https://www.servicenow.com/community/developer-forum/is-it-possible-to-make-a-field-mandatory-and-read-only-in-the/m-p/1929600#M586526</guid>
      <dc:creator>Mairvette Tuck1</dc:creator>
      <dc:date>2020-09-30T15:58:13Z</dc:date>
    </item>
    <item>
      <title>Re: Is it possible to make a field mandatory and read only in the form ? If yes what is the use ?</title>
      <link>https://www.servicenow.com/community/developer-forum/is-it-possible-to-make-a-field-mandatory-and-read-only-in-the/m-p/2827842#M1084000</link>
      <description>&lt;P&gt;Hi Josh, I had a interview question. Can u solve it for me?.&lt;/P&gt;&lt;P&gt;I can make a field as Mandatory, read-only and visible using Dictionary Override and as well as UI Policy. Which one would u chose?&lt;/P&gt;</description>
      <pubDate>Thu, 15 Feb 2024 06:28:43 GMT</pubDate>
      <guid>https://www.servicenow.com/community/developer-forum/is-it-possible-to-make-a-field-mandatory-and-read-only-in-the/m-p/2827842#M1084000</guid>
      <dc:creator>sidduab17</dc:creator>
      <dc:date>2024-02-15T06:28:43Z</dc:date>
    </item>
  </channel>
</rss>

