<?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 Displaying additional Variables based on a Hidden variable's value on a Record Producer in ITSM forum</title>
    <link>https://www.servicenow.com/community/itsm-forum/displaying-additional-variables-based-on-a-hidden-variable-s/m-p/3258429#M540187</link>
    <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;We have a record producer that has 19 variables and 7 Catalog UI Policies. There are 2 questions that we ask on the form that drive whether certain fields become visible or remain hidden.&lt;/P&gt;&lt;P&gt;The first field "Is this a new Application or Module?" (new_application_or_module) is Yes/No with None, and always visible.&lt;/P&gt;&lt;P&gt;The second field is "Does this meet the requirements of a project?" (meet_requirements_of_a_project) is Yes/No with None, and is hidden by default and requires a read and write role of it_project_manager (defined in the variable's Permission tab). It is visible and required if&amp;nbsp;new_application_or_module is No and the user has the it_project_manager role.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;We have 6 additional fields that are hidden by default and need to be displayed when the "Is this a new Application or Module?" is No, and "Does this meet the requirements of a project?" is None or No.&lt;/P&gt;&lt;P&gt;These six fields are&amp;nbsp;&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;additional_information&lt;/LI&gt;&lt;LI&gt;u_impacted_departments&lt;/LI&gt;&lt;LI&gt;iniative_driving_work&lt;/LI&gt;&lt;LI&gt;business_case&lt;/LI&gt;&lt;LI&gt;u_business_relationship_manager&lt;/LI&gt;&lt;LI&gt;target_completion_date&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;These variables do not have any conflicting UI Policies associated with them.&lt;/P&gt;&lt;P&gt;I have tried to write a script in the Catalog UI Policy that did not work. I have also tried to use the following conditions:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="JeremyHoffman_0-1746716373982.png" style="width: 400px;"&gt;&lt;img src="https://www.servicenow.com/community/image/serverpage/image-id/440874iCD3808B90BDEDB75/image-size/medium?v=v2&amp;amp;px=400" role="button" title="JeremyHoffman_0-1746716373982.png" alt="JeremyHoffman_0-1746716373982.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;For the above condition, I have tried using "is not", "is" and set the value accordingly. I have also deselected the "Reverse if false"&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="JeremyHoffman_1-1746716421018.png" style="width: 400px;"&gt;&lt;img src="https://www.servicenow.com/community/image/serverpage/image-id/440875iED730ADD45710A22/image-size/medium?v=v2&amp;amp;px=400" role="button" title="JeremyHoffman_1-1746716421018.png" alt="JeremyHoffman_1-1746716421018.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;and&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="JeremyHoffman_2-1746716617022.png" style="width: 400px;"&gt;&lt;img src="https://www.servicenow.com/community/image/serverpage/image-id/440876i827758BFE979A62F/image-size/medium?v=v2&amp;amp;px=400" role="button" title="JeremyHoffman_2-1746716617022.png" alt="JeremyHoffman_2-1746716617022.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I can get it to work for the user who has the it_project_manager role and can see the "Does this meet the requirements of a project?" question because it becomes visible. However, it does not work for the typical user who does not see that question (it remains hidden).&amp;nbsp;I have also tried setting the Default value to the "Does this meet the requirements of a project?" question to No which hasn't helped.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Early on I tried using a catalog client script but was not successful with that either, sorry I no longer have the code to share. I am not a coder by nature, so that very well could be the solution and I was just coding it wrong.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am hoping someone can help me get this configured properly so the fields show or remain hidden based on the requirements. Please let me know if I need to provide any additional information.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Kind regards,&lt;/P&gt;&lt;P&gt;Jeremy&lt;/P&gt;</description>
    <pubDate>Thu, 08 May 2025 15:13:56 GMT</pubDate>
    <dc:creator>JeremyHoffman</dc:creator>
    <dc:date>2025-05-08T15:13:56Z</dc:date>
    <item>
      <title>Displaying additional Variables based on a Hidden variable's value on a Record Producer</title>
      <link>https://www.servicenow.com/community/itsm-forum/displaying-additional-variables-based-on-a-hidden-variable-s/m-p/3258429#M540187</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;We have a record producer that has 19 variables and 7 Catalog UI Policies. There are 2 questions that we ask on the form that drive whether certain fields become visible or remain hidden.&lt;/P&gt;&lt;P&gt;The first field "Is this a new Application or Module?" (new_application_or_module) is Yes/No with None, and always visible.&lt;/P&gt;&lt;P&gt;The second field is "Does this meet the requirements of a project?" (meet_requirements_of_a_project) is Yes/No with None, and is hidden by default and requires a read and write role of it_project_manager (defined in the variable's Permission tab). It is visible and required if&amp;nbsp;new_application_or_module is No and the user has the it_project_manager role.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;We have 6 additional fields that are hidden by default and need to be displayed when the "Is this a new Application or Module?" is No, and "Does this meet the requirements of a project?" is None or No.&lt;/P&gt;&lt;P&gt;These six fields are&amp;nbsp;&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;additional_information&lt;/LI&gt;&lt;LI&gt;u_impacted_departments&lt;/LI&gt;&lt;LI&gt;iniative_driving_work&lt;/LI&gt;&lt;LI&gt;business_case&lt;/LI&gt;&lt;LI&gt;u_business_relationship_manager&lt;/LI&gt;&lt;LI&gt;target_completion_date&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;These variables do not have any conflicting UI Policies associated with them.&lt;/P&gt;&lt;P&gt;I have tried to write a script in the Catalog UI Policy that did not work. I have also tried to use the following conditions:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="JeremyHoffman_0-1746716373982.png" style="width: 400px;"&gt;&lt;img src="https://www.servicenow.com/community/image/serverpage/image-id/440874iCD3808B90BDEDB75/image-size/medium?v=v2&amp;amp;px=400" role="button" title="JeremyHoffman_0-1746716373982.png" alt="JeremyHoffman_0-1746716373982.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;For the above condition, I have tried using "is not", "is" and set the value accordingly. I have also deselected the "Reverse if false"&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="JeremyHoffman_1-1746716421018.png" style="width: 400px;"&gt;&lt;img src="https://www.servicenow.com/community/image/serverpage/image-id/440875iED730ADD45710A22/image-size/medium?v=v2&amp;amp;px=400" role="button" title="JeremyHoffman_1-1746716421018.png" alt="JeremyHoffman_1-1746716421018.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;and&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="JeremyHoffman_2-1746716617022.png" style="width: 400px;"&gt;&lt;img src="https://www.servicenow.com/community/image/serverpage/image-id/440876i827758BFE979A62F/image-size/medium?v=v2&amp;amp;px=400" role="button" title="JeremyHoffman_2-1746716617022.png" alt="JeremyHoffman_2-1746716617022.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I can get it to work for the user who has the it_project_manager role and can see the "Does this meet the requirements of a project?" question because it becomes visible. However, it does not work for the typical user who does not see that question (it remains hidden).&amp;nbsp;I have also tried setting the Default value to the "Does this meet the requirements of a project?" question to No which hasn't helped.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Early on I tried using a catalog client script but was not successful with that either, sorry I no longer have the code to share. I am not a coder by nature, so that very well could be the solution and I was just coding it wrong.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am hoping someone can help me get this configured properly so the fields show or remain hidden based on the requirements. Please let me know if I need to provide any additional information.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Kind regards,&lt;/P&gt;&lt;P&gt;Jeremy&lt;/P&gt;</description>
      <pubDate>Thu, 08 May 2025 15:13:56 GMT</pubDate>
      <guid>https://www.servicenow.com/community/itsm-forum/displaying-additional-variables-based-on-a-hidden-variable-s/m-p/3258429#M540187</guid>
      <dc:creator>JeremyHoffman</dc:creator>
      <dc:date>2025-05-08T15:13:56Z</dc:date>
    </item>
    <item>
      <title>Re: Displaying additional Variables based on a Hidden variable's value on a Record Producer</title>
      <link>https://www.servicenow.com/community/itsm-forum/displaying-additional-variables-based-on-a-hidden-variable-s/m-p/3258467#M540190</link>
      <description>&lt;P&gt;&lt;a href="https://www.servicenow.com/community/user/viewprofilepage/user-id/128206"&gt;@JeremyHoffman&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I guess the issue is because the hidden field as you cannot getValue of a hidden field to use in condition.&lt;/P&gt;
&lt;P&gt;You can try below approach in client script in three consecutive lines:&lt;/P&gt;
&lt;P&gt;1. Make the field visible&lt;/P&gt;
&lt;P&gt;2. Get the value and store in some var.&lt;/P&gt;
&lt;P&gt;3. Make the field hidden again.&lt;/P&gt;
&lt;P&gt;Now you can use the var value to define the if condition and show/hide the fields.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Hope that helps! Accept the solution and mark as helpful if it does, to benefit future readers.&lt;BR /&gt;Regards,&lt;BR /&gt;Sumanth&lt;/P&gt;</description>
      <pubDate>Thu, 08 May 2025 15:57:50 GMT</pubDate>
      <guid>https://www.servicenow.com/community/itsm-forum/displaying-additional-variables-based-on-a-hidden-variable-s/m-p/3258467#M540190</guid>
      <dc:creator>SumanthDosapati</dc:creator>
      <dc:date>2025-05-08T15:57:50Z</dc:date>
    </item>
    <item>
      <title>Re: Displaying additional Variables based on a Hidden variable's value on a Record Producer</title>
      <link>https://www.servicenow.com/community/itsm-forum/displaying-additional-variables-based-on-a-hidden-variable-s/m-p/3258483#M540191</link>
      <description>&lt;P&gt;&lt;a href="https://www.servicenow.com/community/user/viewprofilepage/user-id/128206"&gt;@JeremyHoffman&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P class=""&gt;You want to display the&amp;nbsp;6 additional fields when:&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;&lt;P class=""&gt;new_application_or_module is "No"&lt;/P&gt;&lt;/LI&gt;&lt;LI&gt;&lt;P class=""&gt;AND (meet_requirements_of_a_project is "None" or "No") or the user doesn't have access to that question (field is hidden)&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I would do the following...&lt;/P&gt;&lt;P class=""&gt;create a Catalog Client Script on the field new_application_or_module. This script will....&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;&lt;P class=""&gt;Check its value.&lt;/P&gt;&lt;/LI&gt;&lt;LI&gt;&lt;P class=""&gt;Try to get the value of meet_requirements_of_a_project (if visible).&lt;/P&gt;&lt;/LI&gt;&lt;LI&gt;&lt;P class=""&gt;Determine if the 6 other fields should be shown or hidden.&lt;/P&gt;&lt;/LI&gt;&lt;/OL&gt;&lt;LI-CODE lang="javascript"&gt;function onChange(control, oldValue, newValue, isLoading) {
    if (isLoading || newValue === '') {
        return;
    }

    // List of fields to toggle
    var fieldsToToggle = [
        'additional_information',
        'u_impacted_departments',
        'iniative_driving_work',
        'business_case',
        'u_business_relationship_manager',
        'target_completion_date'
    ];

    // If answer is "yes", always hide the 6 fields
    if (newValue == 'yes') {
        for (var i = 0; i &amp;lt; fieldsToToggle.length; i++) {
            g_form.setDisplay(fieldsToToggle[i], false);
        }
        return;
    }

    // new_application_or_module is "no", now check the second field
    var meetReqVisible = g_form.isVisible('meet_requirements_of_a_project');
    var meetReqValue = g_form.getValue('meet_requirements_of_a_project');

    // Only show the 6 fields if the second question is not visible OR set to "no" or "none"
    if (!meetReqVisible || meetReqValue == '' || meetReqValue == 'no') {
        for (var j = 0; j &amp;lt; fieldsToToggle.length; j++) {
            g_form.setDisplay(fieldsToToggle[j], true);
        }
    } else {
        for (var k = 0; k &amp;lt; fieldsToToggle.length; k++) {
            g_form.setDisplay(fieldsToToggle[k], false);
        }
    }
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 08 May 2025 16:50:47 GMT</pubDate>
      <guid>https://www.servicenow.com/community/itsm-forum/displaying-additional-variables-based-on-a-hidden-variable-s/m-p/3258483#M540191</guid>
      <dc:creator>folusho</dc:creator>
      <dc:date>2025-05-08T16:50:47Z</dc:date>
    </item>
    <item>
      <title>Re: Displaying additional Variables based on a Hidden variable's value on a Record Producer</title>
      <link>https://www.servicenow.com/community/itsm-forum/displaying-additional-variables-based-on-a-hidden-variable-s/m-p/3260710#M540328</link>
      <description>&lt;P&gt;&lt;a href="https://www.servicenow.com/community/user/viewprofilepage/user-id/38118"&gt;@folusho&lt;/a&gt;&amp;nbsp;Thank you. Your Client script got me going in the right direction and actually helped me uncover a couple of conflicts I had. I ultimately had to create 2 Client scripts. one as you suggested above, with a few tweaks, and one for the&amp;nbsp;meet_requirements_of_a_project.&amp;nbsp;&lt;BR /&gt;Here are the 2 client scripts I now have and are working per our requirements:&lt;BR /&gt;This is the onChange for the new_application_or_module variable (order = 10)&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;function onChange(control, oldValue, newValue, isLoading) {
    if (isLoading || newValue === '') return;

    var fieldsToToggle = [
        'additional_information',
        'u_impacted_departments',
        'iniative_driving_work',
        'business_case',
        'u_business_relationship_manager',
        'target_completion_date',
        'primary_application_impacted',
        'u_caregiver_impact'
    ];

    if (newValue === 'Yes') {
        toggleFields(fieldsToToggle, false);
        return;
    }

    var meetReqVisible = g_form.isVisible('meet_requirements_of_a_project');
    var meetReqValue = g_form.getValue('meet_requirements_of_a_project');

    var showFields = !meetReqVisible || meetReqValue === '' || meetReqValue === 'No';
    toggleFields(fieldsToToggle, showFields);
}

function toggleFields(fields, show) {
    for (var i = 0; i &amp;lt; fields.length; i++) {
        g_form.setDisplay(fields[i], show);
    }
}&lt;/LI-CODE&gt;&lt;P&gt;This is the onChange one for the meet_requirements_of_a_project (order = 20)&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;function onChange(control, oldValue, newValue, isLoading) {
    if (isLoading) return;

    var fieldsToToggle = [
        'additional_information',
        'u_impacted_departments',
        'iniative_driving_work',
        'business_case',
        'u_business_relationship_manager',
        'target_completion_date',
        'primary_application_impacted',
        'u_caregiver_impact'
    ];

    // Show if value is "no" or blank
    var showFields = newValue === '' || newValue === 'No';
    toggleFields(fieldsToToggle, showFields);
}

function toggleFields(fields, show) {
    for (var i = 0; i &amp;lt; fields.length; i++) {
        g_form.setDisplay(fields[i], show);
    }
}&lt;/LI-CODE&gt;</description>
      <pubDate>Mon, 12 May 2025 13:31:02 GMT</pubDate>
      <guid>https://www.servicenow.com/community/itsm-forum/displaying-additional-variables-based-on-a-hidden-variable-s/m-p/3260710#M540328</guid>
      <dc:creator>JeremyHoffman</dc:creator>
      <dc:date>2025-05-12T13:31:02Z</dc:date>
    </item>
    <item>
      <title>Re: Displaying additional Variables based on a Hidden variable's value on a Record Producer</title>
      <link>https://www.servicenow.com/community/itsm-forum/displaying-additional-variables-based-on-a-hidden-variable-s/m-p/3260723#M540329</link>
      <description>&lt;P&gt;&lt;a href="https://www.servicenow.com/community/user/viewprofilepage/user-id/128206"&gt;@JeremyHoffman&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for letting me know and I'm glad this worked for you.&lt;/P&gt;&lt;P&gt;Please can you my response as solution accepted to help others.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Regards.&lt;/P&gt;</description>
      <pubDate>Mon, 12 May 2025 13:38:57 GMT</pubDate>
      <guid>https://www.servicenow.com/community/itsm-forum/displaying-additional-variables-based-on-a-hidden-variable-s/m-p/3260723#M540329</guid>
      <dc:creator>folusho</dc:creator>
      <dc:date>2025-05-12T13:38:57Z</dc:date>
    </item>
  </channel>
</rss>

