<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://community.appian.com/cfs-file/__key/system/syndication/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>How to hide document viewer field once opened?</title><link>https://community.appian.com/discussions/f/user-interface/22269/how-to-hide-document-viewer-field-once-opened</link><description>Hello everyone! 
 Im just toggling with the documentViewerField function and would like to know how to hide the documentViewerField once the user clicks on the dynamic field [that opens up the field]. I&amp;#39;ve tried toggling with the code for a while but</description><dc:language>en-US</dc:language><generator>Telligent Community 12</generator><item><title>RE: How to hide document viewer field once opened?</title><link>https://community.appian.com/thread/87178?ContentTypeID=1</link><pubDate>Thu, 21 Oct 2021 19:47:59 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:366bdf34-d81f-4742-bbe4-f1585f429f72</guid><dc:creator>Arnold Garcia Canaza</dc:creator><description>&lt;p&gt;Oh wow, that&amp;#39;s really cool! :)&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Always something new to learn.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Thank you so much for answering my questions! I really appreciate it.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to hide document viewer field once opened?</title><link>https://community.appian.com/thread/87177?ContentTypeID=1</link><pubDate>Thu, 21 Oct 2021 19:15:28 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:64618f69-497e-42b3-8c71-14494e132db1</guid><dc:creator>Mike Schmitt</dc:creator><description>&lt;p&gt;Yes, you can do that too - either in combination with the separate link or instead of, depending on what you particularly want.&lt;/p&gt;
&lt;p&gt;Here&amp;#39;s an alternative approach to the above code where we alternate between an &amp;quot;open&amp;quot; or a &amp;quot;hide&amp;quot; version of the link depending on whether the current row is the selected document.&amp;nbsp; (It still also shows the &amp;quot;Hide&amp;quot; link below the open document, but you can just get rid of this if you want.)&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="java"&gt;a!localVariables(
  local!documents: {47149, 47150},
  local!selectedDocId,

  a!sectionLayout(
    label: &amp;quot;Section&amp;quot;,
    contents: {
      a!richTextDisplayField(
        value: {
          a!forEach(
            items: local!documents,
            expression: {
              a!richTextItem(
                showWhen: tointeger(local!selectedDocId) &amp;lt;&amp;gt; fv!item,
                text: {
                  document(fv!item, &amp;quot;name&amp;quot;), &amp;quot; &amp;quot;,
                  a!richTextIcon(icon: &amp;quot;search-plus&amp;quot;, color: &amp;quot;POSITIVE&amp;quot;, caption: &amp;quot;View&amp;quot;)
                },
                link: a!dynamicLink(
                  saveInto: {
                    a!save(local!selectedDocId, fv!item)
                  }
                )
              ),
              a!richTextItem(
                showWhen: tointeger(local!selectedDocId) = fv!item,
                text: {
                  document(fv!item, &amp;quot;name&amp;quot;), &amp;quot; &amp;quot;,
                  a!richTextIcon(icon: &amp;quot;search-minus&amp;quot;, color: &amp;quot;NEGATIVE&amp;quot;, caption: &amp;quot;Hide&amp;quot;)
                },
                link: a!dynamicLink(
                  saveInto: {
                    a!save(local!selectedDocId, null())
                  }
                )
              ),
              if(fv!isLast, &amp;quot;&amp;quot;, char(10))
            }
          )
        }
      ),

      a!documentViewerField(
        label: &amp;quot;Selected Document&amp;quot;,
        document: local!selectedDocId,
        showWhen: not(isnull(local!selectedDocId)),
      ),
      
      a!richTextDisplayField(
        showWhen: not(isnull(local!selectedDocId)),
        value: a!richTextItem(
          text: &amp;quot;Hide&amp;quot;,
          link: a!dynamicLink(
            saveInto: {
              a!save(
                local!selectedDocId,
                null()
              )
            }
          )
        )
      )
    }
  )
)&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to hide document viewer field once opened?</title><link>https://community.appian.com/thread/87176?ContentTypeID=1</link><pubDate>Thu, 21 Oct 2021 19:13:56 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:29e1c972-bd38-4c65-97fe-0810aa6ce987</guid><dc:creator>Arnold Garcia Canaza</dc:creator><description>&lt;p&gt;That makes sense! I noticed that the &amp;quot;Hide&amp;quot; dynamic link was created to hide the field, is it possible to have the same dynamic link (That opens the document view field) to also close the document viewer field? Or is that something that would be more complex than having a &amp;quot;hide&amp;quot; dynamic link?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to hide document viewer field once opened?</title><link>https://community.appian.com/thread/87175?ContentTypeID=1</link><pubDate>Thu, 21 Oct 2021 19:03:24 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:27390a16-20df-4b30-bdbb-1dbd1bf75dbd</guid><dc:creator>Mike Schmitt</dc:creator><description>&lt;p&gt;The most important reason to not use a!linkField() is that it has no way of conditionally displaying its link or not.&amp;nbsp; For this reason plus all the benefits offered by the Rich Text field, my recommendation to everyone is to never use it unless there&amp;#39;s an absolute need (which probably doesn&amp;#39;t exist).&lt;/p&gt;
&lt;p&gt;Line 22 inserts a linebreak (&lt;strong&gt;&lt;em&gt;char(10)&lt;/em&gt;&lt;/strong&gt;), otherwise all links would appear on the same row (you can comment out that line temporarily and see what happens).&amp;nbsp; It does this for all but the last instance, hence the if() condition around fv!isLast.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to hide document viewer field once opened?</title><link>https://community.appian.com/thread/87174?ContentTypeID=1</link><pubDate>Thu, 21 Oct 2021 18:58:40 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:4351e857-3136-4f16-8dba-1b7aa361349e</guid><dc:creator>Arnold Garcia Canaza</dc:creator><description>&lt;p&gt;Why would I not use a&amp;nbsp;&lt;span&gt;&amp;nbsp;a!linkField compared to a a!richTextDisplayField? Is it for aesthetic/more functionality reasons? &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Also I was hoping you can explain line 22, is that meant for formatting?&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to hide document viewer field once opened?</title><link>https://community.appian.com/thread/87173?ContentTypeID=1</link><pubDate>Thu, 21 Oct 2021 18:31:57 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:0912d219-ef5f-4626-8a52-e1c4bb546249</guid><dc:creator>Mike Schmitt</dc:creator><description>&lt;p&gt;I recommend never using a!linkField - you should only use a!richTextDisplayField.&amp;nbsp; And yes, the second link would go there.&lt;/p&gt;
&lt;p&gt;As an example I&amp;#39;ve rewritten your above code in my own &amp;quot;style&amp;quot;; here we get a list of all documents provided each as their own link, and clicking any of them will open that document in the viewer field below (notice you can click a second document and it will open that one instead).&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="java"&gt;a!localVariables(
  local!documents: {47149, 47150},
  local!selectedDocId,
  
  a!sectionLayout(
    label: &amp;quot;Section&amp;quot;,
    contents: {
      a!richTextDisplayField(
        value: {
          a!forEach(
            items: local!documents,
            expression: {
              a!richTextItem(
                text: &amp;quot;View Document: &amp;quot; &amp;amp; document(fv!item, &amp;quot;name&amp;quot;),
                link: a!dynamicLink(
                  showWhen: tointeger(local!selectedDocId) &amp;lt;&amp;gt; fv!item,
                  saveInto: {
                    a!save(local!selectedDocId, fv!item)
                  }
                )
              ),
              if(fv!isLast, &amp;quot;&amp;quot;, char(10))
            }
          )
        }
      ),
      
      a!documentViewerField(
        label: &amp;quot;Selected Document&amp;quot;,
        document: local!selectedDocId,
        showWhen: not(isnull(local!selectedDocId)),
      ),
      a!richTextDisplayField(
        showWhen: not(isnull(local!selectedDocId)),
        value: a!richTextItem(
          text: &amp;quot;Hide&amp;quot;,
          link: a!dynamicLink(
            saveInto: {
              a!save(
                local!selectedDocId,
                null()
              )
            }
          )
        )
      )
    }
  )
)&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;Also as a side note, with the Rich Text Display Field, you can do more advanced things based on the selected document ID like changing the formatting of the row(s), hiding the link on the currently-selected row, using different icons, etc.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to hide document viewer field once opened?</title><link>https://community.appian.com/thread/87172?ContentTypeID=1</link><pubDate>Thu, 21 Oct 2021 18:26:52 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:fbeaab07-0115-475a-a5b9-e456b8b1d4c2</guid><dc:creator>Arnold Garcia Canaza</dc:creator><description>&lt;p&gt;would that second link go inside a!linkField ?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to hide document viewer field once opened?</title><link>https://community.appian.com/thread/87171?ContentTypeID=1</link><pubDate>Thu, 21 Oct 2021 18:22:10 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:ce60cb7b-bd24-46df-9372-0f96b383208e</guid><dc:creator>Mike Schmitt</dc:creator><description>&lt;p&gt;You create a second link that saves &amp;quot;null()&amp;quot; back into your local variable.&amp;nbsp; I would suggest you name that variable &amp;quot;local!selectedDocId&amp;quot; instead of &amp;quot;local!link&amp;quot;, because &amp;quot;local!link&amp;quot; is misleading among other things.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>