<?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 Toggling the Visibility of a Repeater Component in UI Builder Using a Button in ServiceNow Studio forum</title>
    <link>https://www.servicenow.com/community/servicenow-studio-forum/toggling-the-visibility-of-a-repeater-component-in-ui-builder/m-p/3119230#M733</link>
    <description>&lt;P&gt;Currently, I am trying to implement a feature in UI Builder that allows toggling the visibility of a specific Repeater component using a button.&lt;/P&gt;&lt;P&gt;Specifically, I want to achieve the following requirements:&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;When the button is clicked, the Repeater component is hidden.&lt;/LI&gt;&lt;LI&gt;Clicking the button again makes the Repeater component visible (toggle between visible and hidden states).&lt;/LI&gt;&lt;/UL&gt;&lt;H3&gt;Steps I have tried so far:&lt;/H3&gt;&lt;OL&gt;&lt;LI&gt;I bound the Repeater’s &lt;STRONG&gt;Component Visibility&lt;/STRONG&gt; to a Client State Parameter (isVisible1), configuring it so that the Repeater is hidden when the value is True and visible when the value is False.&lt;/LI&gt;&lt;LI&gt;I set an &lt;STRONG&gt;Update client state parameter&lt;/STRONG&gt; event for the button and wrote the following script to toggle the value:&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;FONT&gt;&lt;SPAN class=""&gt;function&lt;/SPAN&gt; &lt;SPAN class=""&gt;evaluateEvent&lt;/SPAN&gt;(&lt;SPAN class=""&gt;{api, event}&lt;/SPAN&gt;) { &lt;SPAN class=""&gt;return&lt;/SPAN&gt; { &lt;SPAN class=""&gt;propName&lt;/SPAN&gt;: &lt;SPAN class=""&gt;"isVisible1"&lt;/SPAN&gt;, &lt;SPAN class=""&gt;value&lt;/SPAN&gt;: !api.&lt;SPAN class=""&gt;getState&lt;/SPAN&gt;(&lt;SPAN class=""&gt;"isVisible1"&lt;/SPAN&gt;&lt;/FONT&gt;) }; }&lt;/DIV&gt;&lt;/DIV&gt;&lt;H3&gt;Current Situation:&lt;/H3&gt;&lt;UL&gt;&lt;LI&gt;The Repeater component is successfully hidden on the first button click (even without applying the above script).&lt;/LI&gt;&lt;LI&gt;However, I cannot make it visible again with subsequent clicks.&lt;/LI&gt;&lt;LI&gt;I suspect that the above script is not appropriate for this use case.&lt;/LI&gt;&lt;/UL&gt;&lt;H3&gt;What I would like to know:&lt;/H3&gt;&lt;OL&gt;&lt;LI&gt;If there are any mistakes or missing steps in the above implementation, what should I fix?&lt;/LI&gt;&lt;LI&gt;Is there a way to achieve this visibility toggle functionality using the standard features of UI Builder?&lt;/LI&gt;&lt;/OL&gt;</description>
    <pubDate>Wed, 04 Dec 2024 08:56:18 GMT</pubDate>
    <dc:creator>rt_kaneko</dc:creator>
    <dc:date>2024-12-04T08:56:18Z</dc:date>
    <item>
      <title>Toggling the Visibility of a Repeater Component in UI Builder Using a Button</title>
      <link>https://www.servicenow.com/community/servicenow-studio-forum/toggling-the-visibility-of-a-repeater-component-in-ui-builder/m-p/3119230#M733</link>
      <description>&lt;P&gt;Currently, I am trying to implement a feature in UI Builder that allows toggling the visibility of a specific Repeater component using a button.&lt;/P&gt;&lt;P&gt;Specifically, I want to achieve the following requirements:&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;When the button is clicked, the Repeater component is hidden.&lt;/LI&gt;&lt;LI&gt;Clicking the button again makes the Repeater component visible (toggle between visible and hidden states).&lt;/LI&gt;&lt;/UL&gt;&lt;H3&gt;Steps I have tried so far:&lt;/H3&gt;&lt;OL&gt;&lt;LI&gt;I bound the Repeater’s &lt;STRONG&gt;Component Visibility&lt;/STRONG&gt; to a Client State Parameter (isVisible1), configuring it so that the Repeater is hidden when the value is True and visible when the value is False.&lt;/LI&gt;&lt;LI&gt;I set an &lt;STRONG&gt;Update client state parameter&lt;/STRONG&gt; event for the button and wrote the following script to toggle the value:&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;FONT&gt;&lt;SPAN class=""&gt;function&lt;/SPAN&gt; &lt;SPAN class=""&gt;evaluateEvent&lt;/SPAN&gt;(&lt;SPAN class=""&gt;{api, event}&lt;/SPAN&gt;) { &lt;SPAN class=""&gt;return&lt;/SPAN&gt; { &lt;SPAN class=""&gt;propName&lt;/SPAN&gt;: &lt;SPAN class=""&gt;"isVisible1"&lt;/SPAN&gt;, &lt;SPAN class=""&gt;value&lt;/SPAN&gt;: !api.&lt;SPAN class=""&gt;getState&lt;/SPAN&gt;(&lt;SPAN class=""&gt;"isVisible1"&lt;/SPAN&gt;&lt;/FONT&gt;) }; }&lt;/DIV&gt;&lt;/DIV&gt;&lt;H3&gt;Current Situation:&lt;/H3&gt;&lt;UL&gt;&lt;LI&gt;The Repeater component is successfully hidden on the first button click (even without applying the above script).&lt;/LI&gt;&lt;LI&gt;However, I cannot make it visible again with subsequent clicks.&lt;/LI&gt;&lt;LI&gt;I suspect that the above script is not appropriate for this use case.&lt;/LI&gt;&lt;/UL&gt;&lt;H3&gt;What I would like to know:&lt;/H3&gt;&lt;OL&gt;&lt;LI&gt;If there are any mistakes or missing steps in the above implementation, what should I fix?&lt;/LI&gt;&lt;LI&gt;Is there a way to achieve this visibility toggle functionality using the standard features of UI Builder?&lt;/LI&gt;&lt;/OL&gt;</description>
      <pubDate>Wed, 04 Dec 2024 08:56:18 GMT</pubDate>
      <guid>https://www.servicenow.com/community/servicenow-studio-forum/toggling-the-visibility-of-a-repeater-component-in-ui-builder/m-p/3119230#M733</guid>
      <dc:creator>rt_kaneko</dc:creator>
      <dc:date>2024-12-04T08:56:18Z</dc:date>
    </item>
  </channel>
</rss>

