<?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>Validate in editable grid</title><link>https://community.appian.com/discussions/f/user-interface/35066/validate-in-editable-grid</link><description>Hello All, 
 
 I have an editable grid with multiple rows. 
 I have fav button on each row. I need to validate only one fav is allowed per user. How can I achieve this pls. 
 
 Here validation is not working. All my grid data is coming from ri and saving</description><dc:language>en-US</dc:language><generator>Telligent Community 12</generator><item><title>RE: Validate in editable grid</title><link>https://community.appian.com/thread/135827?ContentTypeID=1</link><pubDate>Fri, 24 May 2024 15:03:28 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:b595ac70-33a4-4efb-8f89-259040018271</guid><dc:creator>Mike Schmitt</dc:creator><description>&lt;p&gt;You&amp;#39;re on the right track, but the structure of your forEach statement is nonsensical as-written (you can&amp;#39;t put the &amp;quot;count&amp;quot; inside the loop, it won&amp;#39;t know what it&amp;#39;s even looking for).&amp;nbsp; My trick is to do the if() statement inside each loop, test for the desired condition, if it&amp;#39;s true return 1, otherwise return 0, and then above the forEach loop, just sum the total output.&amp;nbsp; If more than one &amp;quot;like&amp;quot; is selected (assuming you&amp;#39;ve structured your &amp;quot;fv!item&amp;quot; correctly, which i can&amp;#39;t tell easily), then the sum will result in 2 or greater, and the validation will show.&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="java"&gt;validations: {
  if(
    sum(
      a!forEach(
        items: ri!grid,
        expression: if(
          fv!item[&amp;#39;test}iscorrect&amp;#39;],  /* gonna have to trust you on this one... */
          1,  /* each &amp;quot;liked&amp;quot; entry in the loop will return a value of 1 */
          0   /* otherwise return a value of zero */
        )
      )
    ) &amp;gt; 1,  /* if the sum is more than one, that implies more than 1 &amp;quot;liked&amp;quot; entry */
    &amp;quot;Only one fav can be selected&amp;quot;,
    null()
  )
}&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Validate in editable grid</title><link>https://community.appian.com/thread/135815?ContentTypeID=1</link><pubDate>Fri, 24 May 2024 12:16:06 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:0e3ebe91-a208-4b8d-8a46-42ad098a7128</guid><dc:creator>Roshini M</dc:creator><description>&lt;p&gt;yes in that case you can try this count() part and throw validation in validation parameter. Use the column name directly instead of fv!item. since fv!item won&amp;#39;t have scope in validation parameter&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Validate in editable grid</title><link>https://community.appian.com/thread/135814?ContentTypeID=1</link><pubDate>Fri, 24 May 2024 12:10:02 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:ff0b15c3-fa15-4c60-b594-48f261c70786</guid><dc:creator>Stefan Helzle</dc:creator><description>&lt;p&gt;OK, and that is exactly what my example is about. Just adapt it to your data.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Validate in editable grid</title><link>https://community.appian.com/thread/135812?ContentTypeID=1</link><pubDate>Fri, 24 May 2024 11:39:56 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:52defc54-9149-4d33-9630-3cc23cc5842a</guid><dc:creator>ak0642</dc:creator><description>&lt;p&gt;&lt;span&gt;Thank you . But my requirement is to validate in editable gridlayout in validation section. My code snippet pasted.&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Validate in editable grid</title><link>https://community.appian.com/thread/135811?ContentTypeID=1</link><pubDate>Fri, 24 May 2024 11:39:46 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:b64e5694-1146-4d9a-bd07-edf670ccfed2</guid><dc:creator>ak0642</dc:creator><description>&lt;p&gt;&lt;span&gt;Thank you . But my requirement is to validate in editable gridlayout in validation section. My code snippet pasted.&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Validate in editable grid</title><link>https://community.appian.com/thread/135810?ContentTypeID=1</link><pubDate>Fri, 24 May 2024 11:39:28 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:162af4e4-f640-448b-889b-30e117b52a83</guid><dc:creator>ak0642</dc:creator><description>&lt;p&gt;Thank you Stefen. But my requirement is to validate in editable gridlayout in validation section. My code snippet pasted.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Validate in editable grid</title><link>https://community.appian.com/thread/135799?ContentTypeID=1</link><pubDate>Fri, 24 May 2024 07:39:46 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:1eb64a24-465e-471a-9ae7-910742ad0b80</guid><dc:creator>Roshini M</dc:creator><description>&lt;p&gt;use if(&amp;nbsp;count(where({&amp;lt;favButton_gridData&amp;gt;})) &amp;gt;1,false,true) in the disable parameter of favButton field ( considering favButton as boolean type)&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Validate in editable grid</title><link>https://community.appian.com/thread/135797?ContentTypeID=1</link><pubDate>Fri, 24 May 2024 05:39:37 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:45f4d72d-f612-4bc0-b7c5-f3215754ad3f</guid><dc:creator>Stefan Helzle</dc:creator><description>&lt;p&gt;If this field is a boolean, you can just use the sum() function as true equals 1 and false equals 0. As there might be some null values, use something like the following code snippet.&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;a!localVariables(
  local!values: {1,0,null},
  sum(local!values = true)
)&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;Apply this to the field in your items where you store the favourite value. Then, disable your button, in case the sum is &amp;gt; 1.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Validate in editable grid</title><link>https://community.appian.com/thread/135795?ContentTypeID=1</link><pubDate>Fri, 24 May 2024 05:35:12 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:1a98c567-f6ea-4958-ad0b-67e04897e64c</guid><dc:creator>Konduru Chaitanya</dc:creator><description>&lt;p&gt;Add the saveInto in a local variable which would validate if it is null then the button will be disabled. If not they can use the button.&amp;nbsp;&lt;br /&gt;&lt;br /&gt;Please share the code snippet for an accurate answer.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>