<?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 Remove options from a form on Service Portal (g_form.removeOption() trouble) in Developer forum</title>
    <link>https://www.servicenow.com/community/developer-forum/remove-options-from-a-form-on-service-portal-g-form-removeoption/m-p/1809715#M466641</link>
    <description>&lt;P&gt;Hello all, I need some assistance to the following requirement.&lt;/P&gt;
&lt;P&gt;I have a record producer on SP, where depending on the category selection, only related subcategories are visible.&lt;/P&gt;
&lt;P&gt;For instance, for the category "hardware", only the following subcategories are visible.&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper"&gt;&lt;img src="https://www.servicenow.com/community/image/serverpage/image-id/47560i9960509B3B7F9E67/image-size/large?v=v2&amp;amp;px=999" title="find_real_file.png" alt="find_real_file.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;However, if I change to another category (for example "software"), all the options are not visible (only the option "--None--" is visible). Then, if I return back to the category "hardware", all the previous options (shown on the first image) are not visible any more as shown below.&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper"&gt;&lt;img src="https://www.servicenow.com/community/image/serverpage/image-id/47553i817B805DBF074DC4/image-size/large?v=v2&amp;amp;px=999" title="find_real_file.png" alt="find_real_file.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;I am using a Catalog&amp;nbsp;Client Script (onChange), that gets the value of the field category, and based on that value removes all the unrelated options on the subcategory field. My script looks like this:&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper"&gt;&lt;img src="https://www.servicenow.com/community/image/serverpage/image-id/47554i0A022A4AC8C3DAB9/image-size/large?v=v2&amp;amp;px=999" title="find_real_file.png" alt="find_real_file.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;Any assistance would be really helpful.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you all in advance.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 08 Sep 2020 07:40:24 GMT</pubDate>
    <dc:creator>Student1</dc:creator>
    <dc:date>2020-09-08T07:40:24Z</dc:date>
    <item>
      <title>Remove options from a form on Service Portal (g_form.removeOption() trouble)</title>
      <link>https://www.servicenow.com/community/developer-forum/remove-options-from-a-form-on-service-portal-g-form-removeoption/m-p/1809715#M466641</link>
      <description>&lt;P&gt;Hello all, I need some assistance to the following requirement.&lt;/P&gt;
&lt;P&gt;I have a record producer on SP, where depending on the category selection, only related subcategories are visible.&lt;/P&gt;
&lt;P&gt;For instance, for the category "hardware", only the following subcategories are visible.&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper"&gt;&lt;img src="https://www.servicenow.com/community/image/serverpage/image-id/47560i9960509B3B7F9E67/image-size/large?v=v2&amp;amp;px=999" title="find_real_file.png" alt="find_real_file.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;However, if I change to another category (for example "software"), all the options are not visible (only the option "--None--" is visible). Then, if I return back to the category "hardware", all the previous options (shown on the first image) are not visible any more as shown below.&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper"&gt;&lt;img src="https://www.servicenow.com/community/image/serverpage/image-id/47553i817B805DBF074DC4/image-size/large?v=v2&amp;amp;px=999" title="find_real_file.png" alt="find_real_file.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;I am using a Catalog&amp;nbsp;Client Script (onChange), that gets the value of the field category, and based on that value removes all the unrelated options on the subcategory field. My script looks like this:&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper"&gt;&lt;img src="https://www.servicenow.com/community/image/serverpage/image-id/47554i0A022A4AC8C3DAB9/image-size/large?v=v2&amp;amp;px=999" title="find_real_file.png" alt="find_real_file.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;Any assistance would be really helpful.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you all in advance.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 08 Sep 2020 07:40:24 GMT</pubDate>
      <guid>https://www.servicenow.com/community/developer-forum/remove-options-from-a-form-on-service-portal-g-form-removeoption/m-p/1809715#M466641</guid>
      <dc:creator>Student1</dc:creator>
      <dc:date>2020-09-08T07:40:24Z</dc:date>
    </item>
    <item>
      <title>Re: Remove options from a form on Service Portal (g_form.removeOption() trouble)</title>
      <link>https://www.servicenow.com/community/developer-forum/remove-options-from-a-form-on-service-portal-g-form-removeoption/m-p/1809716#M466642</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Try using format as below&lt;/P&gt;
&lt;P&gt;g_form.removeOption('variable_name','value','label');&lt;/P&gt;
&lt;P&gt;So,&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;g_form.removeOption('subcategory','11','CPU');&lt;/EM&gt; //suppose 11 is value while CPU is label.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In addition, you need to use g_form.addOption() as well. So, for&amp;nbsp; your case suppose&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;if(cat==8)&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;{&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;g_form.removeOption('subcategory','11','CPU');&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;..&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;g_form.addOption('subcategory','7'); //choice you want to show&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;...&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;}&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So, for every .removeOption() you need to use .addOption() to add &amp;amp; make it work independently.&lt;/P&gt;</description>
      <pubDate>Tue, 08 Sep 2020 07:52:12 GMT</pubDate>
      <guid>https://www.servicenow.com/community/developer-forum/remove-options-from-a-form-on-service-portal-g-form-removeoption/m-p/1809716#M466642</guid>
      <dc:creator>Jaspal Singh</dc:creator>
      <dc:date>2020-09-08T07:52:12Z</dc:date>
    </item>
    <item>
      <title>Re: Remove options from a form on Service Portal (g_form.removeOption() trouble)</title>
      <link>https://www.servicenow.com/community/developer-forum/remove-options-from-a-form-on-service-portal-g-form-removeoption/m-p/1809717#M466643</link>
      <description>&lt;P&gt;Thank you!! It seems that it works without any issues.&lt;/P&gt;
&lt;P&gt;Regards,&lt;/P&gt;
&lt;P&gt;Tomas.&lt;/P&gt;</description>
      <pubDate>Tue, 08 Sep 2020 08:18:11 GMT</pubDate>
      <guid>https://www.servicenow.com/community/developer-forum/remove-options-from-a-form-on-service-portal-g-form-removeoption/m-p/1809717#M466643</guid>
      <dc:creator>Student1</dc:creator>
      <dc:date>2020-09-08T08:18:11Z</dc:date>
    </item>
    <item>
      <title>Re: Remove options from a form on Service Portal (g_form.removeOption() trouble)</title>
      <link>https://www.servicenow.com/community/developer-forum/remove-options-from-a-form-on-service-portal-g-form-removeoption/m-p/1809718#M466644</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;While you got the solution, one thing to notice is to remove a option, you need only the fieldname and value. You don't need label.&lt;/P&gt;
&lt;P&gt;Ref:&amp;nbsp;&lt;A href="https://developer.servicenow.com/dev.do#!/reference/api/orlando/client/c_GlideFormAPI#r_GlideFormRemoveOption_String_String?navFilter=removeOption" target="_blank"&gt;https://developer.servicenow.com/dev.do#!/reference/api/orlando/client/c_GlideFormAPI#r_GlideFormRemoveOption_String_String?navFilter=removeOption&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;Ex:&amp;nbsp;&lt;EM data-ce-key="967"&gt;g_form.removeOption('subcategory','11');&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;But For add, you need 3 arguments fieldname, value, label&lt;/P&gt;
&lt;P&gt;Ex:&amp;nbsp;&lt;EM data-ce-key="971"&gt;g_form.addOption('subcategory','7','Label'); //choice you want to show&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;&lt;EM data-ce-key="971"&gt;Ref:&amp;nbsp;&lt;A href="https://developer.servicenow.com/dev.do#!/reference/api/orlando/client/c_GlideFormAPI#r_GlideformAddOption_String_String_String?navFilter=addOption" target="_blank"&gt;https://developer.servicenow.com/dev.do#!/reference/api/orlando/client/c_GlideFormAPI#r_GlideformAddOption_String_String_String?navFilter=addOption&lt;/A&gt;&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;&lt;EM data-ce-key="971"&gt;Mark the comment as helpful if it helps.&lt;/EM&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 08 Sep 2020 08:29:43 GMT</pubDate>
      <guid>https://www.servicenow.com/community/developer-forum/remove-options-from-a-form-on-service-portal-g-form-removeoption/m-p/1809718#M466644</guid>
      <dc:creator>asifnoor</dc:creator>
      <dc:date>2020-09-08T08:29:43Z</dc:date>
    </item>
    <item>
      <title>Re: Remove options from a form on Service Portal (g_form.removeOption() trouble)</title>
      <link>https://www.servicenow.com/community/developer-forum/remove-options-from-a-form-on-service-portal-g-form-removeoption/m-p/1809719#M466645</link>
      <description>&lt;P&gt;Thank you very much.&lt;/P&gt;
&lt;P&gt;It helps, since I am new to SN.&lt;/P&gt;
&lt;P&gt;Thanks again for your time.&lt;/P&gt;</description>
      <pubDate>Tue, 08 Sep 2020 08:41:21 GMT</pubDate>
      <guid>https://www.servicenow.com/community/developer-forum/remove-options-from-a-form-on-service-portal-g-form-removeoption/m-p/1809719#M466645</guid>
      <dc:creator>Student1</dc:creator>
      <dc:date>2020-09-08T08:41:21Z</dc:date>
    </item>
    <item>
      <title>Re: Remove options from a form on Service Portal (g_form.removeOption() trouble)</title>
      <link>https://www.servicenow.com/community/developer-forum/remove-options-from-a-form-on-service-portal-g-form-removeoption/m-p/1809720#M466646</link>
      <description>&lt;P&gt;No problem. All the best to your learning.&lt;/P&gt;</description>
      <pubDate>Tue, 08 Sep 2020 08:43:51 GMT</pubDate>
      <guid>https://www.servicenow.com/community/developer-forum/remove-options-from-a-form-on-service-portal-g-form-removeoption/m-p/1809720#M466646</guid>
      <dc:creator>asifnoor</dc:creator>
      <dc:date>2020-09-08T08:43:51Z</dc:date>
    </item>
    <item>
      <title>Re: Remove options from a form on Service Portal (g_form.removeOption() trouble)</title>
      <link>https://www.servicenow.com/community/developer-forum/remove-options-from-a-form-on-service-portal-g-form-removeoption/m-p/2859582#M1093797</link>
      <description>&lt;P&gt;Good info Jaspal.&lt;/P&gt;&lt;P&gt;I found that by adding the value and label ONLY to the removeOption worked great, however, I'd have a blank space below my choice list. Weird.&lt;/P&gt;&lt;P&gt;So I also added the value and label to the addOption function and it worked great.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This is in Vancouver&lt;/P&gt;</description>
      <pubDate>Tue, 12 Mar 2024 14:49:27 GMT</pubDate>
      <guid>https://www.servicenow.com/community/developer-forum/remove-options-from-a-form-on-service-portal-g-form-removeoption/m-p/2859582#M1093797</guid>
      <dc:creator>magee</dc:creator>
      <dc:date>2024-03-12T14:49:27Z</dc:date>
    </item>
  </channel>
</rss>

