<?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>Duplicate in the grid</title><link>https://community.appian.com/discussions/f/user-interface/29155/duplicate-in-the-grid</link><description>Hi, 
 I have a grid layout and the values are populated from my selection. I need to check, if there are duplicated values present in the grid. If there are duplicate values present, I should not able to submit the form. I store my selection in a local</description><dc:language>en-US</dc:language><generator>Telligent Community 12</generator><item><title>RE: Duplicate in the grid</title><link>https://community.appian.com/thread/115214?ContentTypeID=1</link><pubDate>Wed, 28 Jun 2023 14:32:17 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:0e64377f-edbf-4740-ae52-3eb24cac59eb</guid><dc:creator>Mike Schmitt</dc:creator><description>&lt;p&gt;You can add a validation item on your grid, which checks whether there are duplicate values within that column.&amp;nbsp; I wrote a rule a while ago which looks into an array and returns any items that are duplicated within the array any number of times, which I&amp;#39;ll share below.&lt;/p&gt;
&lt;p&gt;For the validation message on your grid:&lt;br /&gt;&lt;pre class="ui-code" data-mode="java"&gt;a!validationMessage(
  message: &amp;quot;Duplicate Amounts are present.&amp;quot;,
  validateAfter: &amp;quot;SUBMIT&amp;quot;,
  showWhen: length(
    rule!GLBL_getArrayDuplicates(local!gridData.Amount)
  ) &amp;gt; 0
)&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;For the rule &lt;strong&gt;&lt;em&gt;GLBL_getArrayDuplicates()&lt;/em&gt;&lt;/strong&gt;:&lt;br /&gt;&lt;pre class="ui-code" data-mode="java"&gt;a!flatten(
  a!forEach(
    ri!array,
    if(
      length(wherecontains(
        fv!item,
        cast(typeof({fv!item}), ri!array)  /* (this allows us to handle a mixed-type array properly) */
      )) &amp;gt; 1,
      fv!item,
      {}
    )
  )
)&lt;/pre&gt;&lt;br /&gt;&lt;img src="/resized-image/__size/320x240/__key/communityserver-discussions-components-files/13/pastedimage1687962723633v1.png" alt=" " /&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Duplicate in the grid</title><link>https://community.appian.com/thread/115213?ContentTypeID=1</link><pubDate>Wed, 28 Jun 2023 14:23:39 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:83a39eaf-d2d4-4670-b972-64f231bf2690</guid><dc:creator>hema.mathivathanan</dc:creator><description>&lt;p&gt;In the grid, for a particular field I select values from another table. The selected value appears in the grid.&amp;nbsp;&lt;br /&gt;Now, I am able to select the same value twice. But, it should not happen.&lt;br /&gt;&lt;br /&gt;For example, if I have the same value twice, it should throw the error, &amp;quot;duplicate values are present&amp;quot;. please check&lt;br /&gt;&lt;img src="/resized-image/__size/320x240/__key/communityserver-discussions-components-files/13/pastedimage1687962174626v1.png" alt=" " /&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Duplicate in the grid</title><link>https://community.appian.com/thread/115211?ContentTypeID=1</link><pubDate>Wed, 28 Jun 2023 14:20:12 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:dc31809d-86c6-49db-80dd-d74f4c1de33f</guid><dc:creator>Mike Schmitt</dc:creator><description>&lt;p&gt;What would &amp;quot;duplicate values&amp;quot; look like in this case?&amp;nbsp; Are you talking about a grid of data being created / populated by the user at run-time, or something else?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>