<?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 MRVS field Mandatory when Variable Set (Checkbox) is True in Developer forum</title>
    <link>https://www.servicenow.com/community/developer-forum/setting-mrvs-field-mandatory-when-variable-set-checkbox-is-true/m-p/2734814#M1054830</link>
    <description>&lt;P&gt;You are welcome!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="comic sans ms,sans-serif" size="2"&gt;Connect with me &lt;A href="https://www.linkedin.com/in/brad-bowman-321b1567/" target="_blank" rel="noopener"&gt;https://www.linkedin.com/in/brad-bowman-321b1567/&lt;/A&gt;&lt;/FONT&gt;&lt;/P&gt;</description>
    <pubDate>Thu, 16 Nov 2023 14:17:20 GMT</pubDate>
    <dc:creator>Brad Bowman</dc:creator>
    <dc:date>2023-11-16T14:17:20Z</dc:date>
    <item>
      <title>Setting MRVS field Mandatory when Variable Set (Checkbox) is True</title>
      <link>https://www.servicenow.com/community/developer-forum/setting-mrvs-field-mandatory-when-variable-set-checkbox-is-true/m-p/2733883#M1054585</link>
      <description>&lt;P&gt;Good day,&lt;/P&gt;&lt;P&gt;Im trying to set a Variable in a MRVS mandatory. i know the basic ways to do this but the problem im having is there is a requirement to make it that way when a checkbox is Check(true). the check box lives in a Variable set.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;so i created a Catalog Script and it goes as following&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Applies to (catalog Item)&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Type&amp;nbsp; (onChange)&lt;/P&gt;&lt;P&gt;Catalog Items&amp;nbsp; (Banking)&lt;/P&gt;&lt;P&gt;Variable name&amp;nbsp; (v_needed_checkbox)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have it to apply to the Catalog Item, Requested Item and Task item Views&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This is the code i wrote but im going in the wrong direction or something is wrong&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;function onChange (control, oldValue, newValue, isLoading)&lt;/P&gt;&lt;P&gt;if (isLoading || newValue == '') {&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;if (g_form.getValue('v_needed_checkbox' == true)) {&amp;nbsp; &amp;nbsp; //Variable set (card collection)&lt;/P&gt;&lt;P&gt;g_form.setMandatory('business_bank_card.approving_user_id' , true);{&amp;nbsp; // Multi Row Variable set&amp;nbsp; (approval info)&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;can you provide your throughts on the best way to make this variable Manadatory&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 15 Nov 2023 20:13:58 GMT</pubDate>
      <guid>https://www.servicenow.com/community/developer-forum/setting-mrvs-field-mandatory-when-variable-set-checkbox-is-true/m-p/2733883#M1054585</guid>
      <dc:creator>Walter Toney</dc:creator>
      <dc:date>2023-11-15T20:13:58Z</dc:date>
    </item>
    <item>
      <title>Re: Setting MRVS field Mandatory when Variable Set (Checkbox) is True</title>
      <link>https://www.servicenow.com/community/developer-forum/setting-mrvs-field-mandatory-when-variable-set-checkbox-is-true/m-p/2733893#M1054589</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://www.servicenow.com/community/user/viewprofilepage/user-id/161959"&gt;@Walter Toney&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Please confirm, if this client script defined at multi-row set level of at catalog level.&amp;nbsp;&lt;/P&gt;&lt;P&gt;I think, when we click on ADD button for adding items in multi-row then multi-row form should check this "&lt;SPAN&gt;&lt;EM&gt;&lt;STRONG&gt;v_needed_checkbox&lt;/STRONG&gt;&lt;/EM&gt;" condition,&amp;nbsp; so this client script should part of&amp;nbsp;multi-row definition.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;-Thanks,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;AshishKMishra&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 15 Nov 2023 20:26:53 GMT</pubDate>
      <guid>https://www.servicenow.com/community/developer-forum/setting-mrvs-field-mandatory-when-variable-set-checkbox-is-true/m-p/2733893#M1054589</guid>
      <dc:creator>AshishKM</dc:creator>
      <dc:date>2023-11-15T20:26:53Z</dc:date>
    </item>
    <item>
      <title>Re: Setting MRVS field Mandatory when Variable Set (Checkbox) is True</title>
      <link>https://www.servicenow.com/community/developer-forum/setting-mrvs-field-mandatory-when-variable-set-checkbox-is-true/m-p/2733897#M1054590</link>
      <description>&lt;P&gt;Hi Walter,&lt;/P&gt;
&lt;P&gt;In this case, you'll want to make the variable mandatory &lt;EM&gt;when&lt;/EM&gt; you are adding or editing a row, &lt;EM&gt;after&lt;/EM&gt; checking the value of the checkbox variable.&amp;nbsp; Note that this won't enforce the mandatory variable within the MRVS for rows that are added before the box is checked, but you can create a separate onSubmit script to validate that all rows have a value for this variable, if this scenario is likely to occur.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So you'll want an onLoad Catalog Client Script that applies to the MRVS, not the Catalog Item.&amp;nbsp; Your script would look like this:&lt;/P&gt;
&lt;LI-CODE lang="javascript"&gt;function onLoad() {
	if (g_service_catalog.parent.getValue('v_needed_checkbox') == true) { //if this doesn't work, try 'true'
		g_form.setMandatory('approving_user_id', true); //mrvs variable name
	}
}&lt;/LI-CODE&gt;
&lt;P&gt;I'm assuming in your example 'business_bank_card' is the name of the MRVS and 'approving_user_id' is the name of the MRVS variable?&lt;/P&gt;</description>
      <pubDate>Wed, 15 Nov 2023 20:51:38 GMT</pubDate>
      <guid>https://www.servicenow.com/community/developer-forum/setting-mrvs-field-mandatory-when-variable-set-checkbox-is-true/m-p/2733897#M1054590</guid>
      <dc:creator>Brad Bowman</dc:creator>
      <dc:date>2023-11-15T20:51:38Z</dc:date>
    </item>
    <item>
      <title>Re: Setting MRVS field Mandatory when Variable Set (Checkbox) is True</title>
      <link>https://www.servicenow.com/community/developer-forum/setting-mrvs-field-mandatory-when-variable-set-checkbox-is-true/m-p/2734802#M1054826</link>
      <description>&lt;P&gt;Brad,&amp;nbsp; &amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you for your solution. it worked perfectly. I did have to add the ('true') for the "if" portion of the script.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;function onLoad() {
	if (g_service_catalog.parent.getValue('v_needed_checkbox') == true) { //if this doesn't work, try 'true'
		g_form.setMandatory('approving_user_id', true); //mrvs variable name
	}
}&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 16 Nov 2023 14:11:52 GMT</pubDate>
      <guid>https://www.servicenow.com/community/developer-forum/setting-mrvs-field-mandatory-when-variable-set-checkbox-is-true/m-p/2734802#M1054826</guid>
      <dc:creator>Walter Toney</dc:creator>
      <dc:date>2023-11-16T14:11:52Z</dc:date>
    </item>
    <item>
      <title>Re: Setting MRVS field Mandatory when Variable Set (Checkbox) is True</title>
      <link>https://www.servicenow.com/community/developer-forum/setting-mrvs-field-mandatory-when-variable-set-checkbox-is-true/m-p/2734814#M1054830</link>
      <description>&lt;P&gt;You are welcome!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="comic sans ms,sans-serif" size="2"&gt;Connect with me &lt;A href="https://www.linkedin.com/in/brad-bowman-321b1567/" target="_blank" rel="noopener"&gt;https://www.linkedin.com/in/brad-bowman-321b1567/&lt;/A&gt;&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 16 Nov 2023 14:17:20 GMT</pubDate>
      <guid>https://www.servicenow.com/community/developer-forum/setting-mrvs-field-mandatory-when-variable-set-checkbox-is-true/m-p/2734814#M1054830</guid>
      <dc:creator>Brad Bowman</dc:creator>
      <dc:date>2023-11-16T14:17:20Z</dc:date>
    </item>
  </channel>
</rss>

