<?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>field condition</title><link>https://community.appian.com/discussions/f/general/34561/field-condition</link><description>Hello everyone, 
 Here is the code for a field. When the user gives an input, there are some controls that should be verified. I want to add some code so that if the user gives an input that doesn&amp;#39;t satisfy the condition, the field should be initialized</description><dc:language>en-US</dc:language><generator>Telligent Community 12</generator><item><title>RE: field condition</title><link>https://community.appian.com/thread/132575?ContentTypeID=1</link><pubDate>Thu, 04 Apr 2024 12:33:33 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:7d24fe4a-bd03-4c3f-8af4-ed9d164ee664</guid><dc:creator>Mike Schmitt</dc:creator><description>[quote userid="273734" url="~/discussions/f/general/34561/field-condition/132523"]should i give the if condition in the saveInto instead of the validation ?[/quote]
&lt;p&gt;They are mutually exclusive.&amp;nbsp; You can do either, but you need to pick one.&amp;nbsp;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;If you just have the validation (which is the more common way), the field will just show the error message when an invalid value is entered.&amp;nbsp;&lt;/li&gt;
&lt;li&gt;If you use the SaveInto override like I did above, then regardless of what you put for the validation, the field itself will not allow saving of an invalid value (making the validation message irrelevant, since it would not be possible to have a condition in which it shows).&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;Technically of course you can just have both, but as I mentioned, the validation won&amp;#39;t effectively do anything in this case, so it only adds to code complexity and confusion by leaving it there when it&amp;#39;s not doing anything.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: field condition</title><link>https://community.appian.com/thread/132523?ContentTypeID=1</link><pubDate>Wed, 03 Apr 2024 20:01:26 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:fd72a318-2428-43c7-96a2-498dbf20a216</guid><dc:creator>hrshkar</dc:creator><description>&lt;p&gt;should i give the if condition in the saveInto instead of the validation ?&amp;nbsp;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;if(

and(

not(isnull(ri!record[&amp;#39;recordType!{3e104763-60d6-49a4-8cdb-405e073de678}PBY pr&amp;#234;t.fields.{0f648b9f-079f-483f-87ad-d8a64c53802e}montantApport&amp;#39;])),

not(isnull(ri!record[&amp;#39;recordType!{3e104763-60d6-49a4-8cdb-405e073de678}PBY pr&amp;#234;t.fields.{5c6f5fa8-85d3-4b23-af45-80a1b6b0c364}montantPret&amp;#39;]))

),

if(

ri!record[&amp;#39;recordType!{3e104763-60d6-49a4-8cdb-405e073de678}PBY pr&amp;#234;t.fields.{0f648b9f-079f-483f-87ad-d8a64c53802e}montantApport&amp;#39;] &amp;lt; (0.2 * ri!record[&amp;#39;recordType!{3e104763-60d6-49a4-8cdb-405e073de678}PBY pr&amp;#234;t.fields.{5c6f5fa8-85d3-4b23-af45-80a1b6b0c364}montantPret&amp;#39;]),

&amp;quot;Le montant de l&amp;#39;apport doit &amp;#234;tre au moins &amp;#233;gal &amp;#224; 20% du montant demand&amp;#233; pour le pr&amp;#234;t.&amp;quot;,

null

),

null





)&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: field condition</title><link>https://community.appian.com/thread/132505?ContentTypeID=1</link><pubDate>Wed, 03 Apr 2024 15:00:41 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:80626411-2673-4d36-a8ef-9ee01a1bec72</guid><dc:creator>Mike Schmitt</dc:creator><description>[quote userid="174515" url="~/discussions/f/general/34561/field-condition/132502"]I&amp;#39;ve added an if condition inside the existing validation block. If the user input doesn&amp;#39;t satisfy the condition (i.e., if the amount entered is less than 20% of montantPret), the a!save function is used to reset the value of the montantApport field to null[/quote]
&lt;p&gt;This would be an interesting approach, except it&amp;#39;s &lt;em&gt;&lt;span style="text-decoration:underline;"&gt;nonsense&lt;/span&gt;&lt;/em&gt;.&amp;nbsp; You can&amp;#39;t call &lt;em&gt;a!save()&lt;/em&gt; inside the &lt;strong&gt;validations&lt;/strong&gt; parameter.&amp;nbsp; At all.&lt;/p&gt;
[quote userid="174515" url="~/discussions/f/general/34561/field-condition/132502"]a!setValue([/quote]
&lt;p&gt;Additionally there is no such function as &lt;em&gt;&lt;strong&gt;a!setValue()&lt;/strong&gt;&lt;/em&gt;.&amp;nbsp; Is your answer written by ChatGPT or something?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: field condition</title><link>https://community.appian.com/thread/132502?ContentTypeID=1</link><pubDate>Wed, 03 Apr 2024 14:50:04 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:7b5b627a-7098-47bd-9a4c-343b04d3ce04</guid><dc:creator>manishs0028</dc:creator><description>&lt;p&gt;To initialize the field as empty if the user input doesn&amp;#39;t satisfy the condition, you can add additional logic to the validation block. &lt;br /&gt;if condition inside the existing validation block. If the user input doesn&amp;#39;t satisfy the condition (i.e., if the amount entered is less than 20% of montantPret), the a!save function is used to reset the value of the montantApport field to null, effectively initializing it as empty.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: field condition</title><link>https://community.appian.com/thread/132499?ContentTypeID=1</link><pubDate>Wed, 03 Apr 2024 14:23:28 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:2b254fc0-993e-4924-83a5-649d0923d613</guid><dc:creator>Mike Schmitt</dc:creator><description>&lt;p&gt;&lt;em&gt;&lt;strong&gt;a!save()&lt;/strong&gt;&lt;/em&gt; is your friend.&lt;/p&gt;
&lt;p&gt;You didn&amp;#39;t really specify what condition you were imagining, so I&amp;#39;ll go ahead and offer a straightforward example:&lt;br /&gt;&lt;pre class="ui-code" data-mode="java"&gt;a!localVariables(
  local!myInteger: null(),
  
  a!integerField(
    label: &amp;quot;Positive Integer Only&amp;quot;,
    value: local!myInteger,
    saveInto: {
      a!save(
        local!myInteger,
        if(save!value &amp;lt; 0, null(), save!value)
      )
    }
  )
)&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;This will, of course, check the user input and, if it fails the condition (being greater than zero), it saves NULL into the local variable, and otherwise, saves the entered value.&amp;nbsp; The condition here is arbitrary - you can make the condition anything that you can write as the boolean condition of an if() statement.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>