<?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 Client script in Community Central forum</title>
    <link>https://www.servicenow.com/community/community-central-forum/client-script/m-p/3377791#M4600</link>
    <description>&lt;P&gt;Hii&amp;nbsp;&lt;/P&gt;&lt;P&gt;If service portal in location offshore select means automatic to select country in india and cities are selected Hyderabad, Bengaluru, Chennai to select in automatically how and what shill I do please explain&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 11 Sep 2025 15:23:44 GMT</pubDate>
    <dc:creator>RavikumarY</dc:creator>
    <dc:date>2025-09-11T15:23:44Z</dc:date>
    <item>
      <title>Client script</title>
      <link>https://www.servicenow.com/community/community-central-forum/client-script/m-p/3377791#M4600</link>
      <description>&lt;P&gt;Hii&amp;nbsp;&lt;/P&gt;&lt;P&gt;If service portal in location offshore select means automatic to select country in india and cities are selected Hyderabad, Bengaluru, Chennai to select in automatically how and what shill I do please explain&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 11 Sep 2025 15:23:44 GMT</pubDate>
      <guid>https://www.servicenow.com/community/community-central-forum/client-script/m-p/3377791#M4600</guid>
      <dc:creator>RavikumarY</dc:creator>
      <dc:date>2025-09-11T15:23:44Z</dc:date>
    </item>
    <item>
      <title>Re: Client script</title>
      <link>https://www.servicenow.com/community/community-central-forum/client-script/m-p/3377923#M4614</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://www.servicenow.com/community/user/viewprofilepage/user-id/949153"&gt;@RavikumarY&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;You can achieve this behavior using a Catalog Client Script (onChange) in ServiceNow.....&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;function onChange(control, oldValue, newValue, isLoading) {
    if (isLoading) {
        return;
    }

    // Field names – replace with your actual variable names
    var locFieldName = 'location';
    var countryFieldName = 'country';
    var cityFieldName = 'city';

    // If location changed to "Offshore"
    if (newValue === 'Offshore') {
        // Set country to India
        g_form.setValue(countryFieldName, 'India');

        // Clear city options and add only specific ones
        g_form.clearOptions(cityFieldName);

        // Add cities
        g_form.addOption(cityFieldName, 'Hyderabad', 'Hyderabad');
        g_form.addOption(cityFieldName, 'Bengaluru', 'Bengaluru');
        g_form.addOption(cityFieldName, 'Chennai', 'Chennai');

        // Optionally set a default city (say Hyderabad)
        g_form.setValue(cityFieldName, 'Hyderabad');

    } else {
        // If location is not offshore, maybe reset country &amp;amp; cities

        // Reset country
        g_form.setValue(countryFieldName, '');

        // Clear city options and restore all city choices (if you have static list)
        g_form.clearOptions(cityFieldName);

        // Example of adding back all city options
        // these should include the others that were removed earlier
        g_form.addOption(cityFieldName, 'Hyderabad', 'Hyderabad');
        g_form.addOption(cityFieldName, 'Bengaluru', 'Bengaluru');
        g_form.addOption(cityFieldName, 'Chennai', 'Chennai');
        g_form.addOption(cityFieldName, 'Mumbai', 'Mumbai');
        g_form.addOption(cityFieldName, 'Delhi', 'Delhi');
        // etc.

        // Optionally set city to blank
        g_form.setValue(cityFieldName, '');
    }
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;If you found my response helpful, please mark it as &lt;STRONG&gt;‘Accept as Solution’&lt;/STRONG&gt; and &lt;STRONG&gt;‘Helpful’.&lt;/STRONG&gt; This helps other community members find the right answer more easily and supports the community.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 11 Sep 2025 16:41:50 GMT</pubDate>
      <guid>https://www.servicenow.com/community/community-central-forum/client-script/m-p/3377923#M4614</guid>
      <dc:creator>kaushal_snow</dc:creator>
      <dc:date>2025-09-11T16:41:50Z</dc:date>
    </item>
  </channel>
</rss>

