<?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 validate fields on hidden section?</title><link>https://community.appian.com/discussions/f/user-interface/19936/how-to-validate-fields-on-hidden-section</link><description>Hi, 
 I have a form with 2 button tabs A and B. Each one displays a section with fields (section A and Section B). 
 Initially, the section A is visible (section B not visible). 
 How may I validate the fields of the section B? 
 My Submit button validates</description><dc:language>en-US</dc:language><generator>Telligent Community 12</generator><item><title>RE: How to validate fields on hidden section?</title><link>https://community.appian.com/thread/77931?ContentTypeID=1</link><pubDate>Tue, 17 Nov 2020 18:09:12 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:44cf457c-6a43-4348-be61-abc01ee4d50c</guid><dc:creator>cedric02</dc:creator><description>&lt;p&gt;Thanks a lot Chris, I did the same using RI (because of my sub-interfaces)&lt;/p&gt;
&lt;p&gt;but unfortunaltely, because of my sub-interfaces, testing all these fields at the top-level is not a good solution.&lt;/p&gt;
&lt;p&gt;For 2 fields, it works well, but for 30 fields I have to find another way to do it.&lt;/p&gt;
&lt;p&gt;The top-level section does not have to know all these fields of Sections A and B (and neither to have to test it). The top-level section just has to display an error message or not.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to validate fields on hidden section?</title><link>https://community.appian.com/thread/77929?ContentTypeID=1</link><pubDate>Tue, 17 Nov 2020 18:05:49 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:f791a38f-ad2f-4cae-88c6-1f95bbf33d19</guid><dc:creator>Chris</dc:creator><description>&lt;p&gt;Here&amp;#39;s an updated example, essentially the validations are stored at the top level a!localVariables and reused in both sections:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;a!localVariables(
  local!fieldA1,
  local!fieldA2,
  local!fieldB1,
  local!fieldB2,
  local!display: &amp;quot;Section A&amp;quot;,
  
  local!sectionAValidations: reject(
    rule!APN_isEmpty,
    {
      if(and(rule!APN_isEmpty(local!fieldA1),rule!APN_isEmpty(local!fieldA2)),&amp;quot;Section A: Enter either field A or field B&amp;quot;,null)
    }
  ),
  local!sectionBValidations: reject(
    rule!APN_isEmpty,
    {
      if(rule!APN_isEmpty(local!fieldB1),&amp;quot;Section B: Field B1 is required&amp;quot;,null),
      if(rule!APN_isEmpty(local!fieldB2),&amp;quot;Section B: Field B2 is required&amp;quot;,null)
    }
  ),
  
  local!validations: reject(
    rule!APN_isEmpty,
    {
      local!sectionAValidations,
      local!sectionBValidations
    }
  ),

  {
    /*top level section*/
    a!sectionLayout(
      label: &amp;quot;Validation Info&amp;quot;,
      validations: local!validations
    ),
    
    a!buttonArrayLayout(
      align: &amp;quot;START&amp;quot;,
      buttons: {
        a!buttonWidget(
          label: &amp;quot;Section A&amp;quot;,
          value: &amp;quot;Section A&amp;quot;,
          disabled: local!display=&amp;quot;Section A&amp;quot;,
          saveInto: local!display
        ),
        a!buttonWidget(
          label: &amp;quot;Section B&amp;quot;,
          value: &amp;quot;Section B&amp;quot;,
          disabled: local!display=&amp;quot;Section B&amp;quot;,
          saveInto: local!display
        )
      }
    ),

    a!sectionLayout(
      label: &amp;quot;Section A&amp;quot;,
      showWhen: local!display=&amp;quot;Section A&amp;quot;,
      validations: local!sectionAValidations,
      contents: {
        a!textField(
          label: &amp;quot;Field A1&amp;quot;,
          value: local!fieldA1,
          saveInto: local!fieldA1,
          required: rule!APN_isEmpty(local!fieldA2)
        ),
        a!textField(
          label: &amp;quot;Field A2&amp;quot;,
          value: local!fieldA2,
          saveInto: local!fieldA2,
          required: rule!APN_isEmpty(local!fieldA1)
        )
      }
    ),
    a!sectionLayout(
      label: &amp;quot;Section B&amp;quot;,
      showWhen: local!display=&amp;quot;Section B&amp;quot;,
      validations: local!sectionBValidations,
      contents: {
        a!textField(
          label: &amp;quot;Field B1&amp;quot;,
          value: local!fieldB1,
          saveInto: local!fieldB1,
          required: true
        ),
        a!textField(
          label: &amp;quot;Field B2&amp;quot;,
          value: local!fieldB2,
          saveInto: local!fieldB2,
          required: true
        )
      }
    )
  }
)&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to validate fields on hidden section?</title><link>https://community.appian.com/thread/77923?ContentTypeID=1</link><pubDate>Tue, 17 Nov 2020 17:43:05 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:3985bb93-a9c9-46ec-a267-9fb8fd992b2b</guid><dc:creator>cedric02</dc:creator><description>&lt;p&gt;Thank you Chris, it works great but you don&amp;#39;t use the&amp;nbsp;validation of SectionA and SectionB...&lt;/p&gt;
&lt;p&gt;I would have&amp;nbsp;love&amp;nbsp;to keep the validation of these 2 sections, as&amp;nbsp;these later are in 2 sub-interfaces.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;/p&gt;
&lt;p&gt;Is there not any way to reuse the validations and then transmit it (as an object reference) to the main form interface?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to validate fields on hidden section?</title><link>https://community.appian.com/thread/77921?ContentTypeID=1</link><pubDate>Tue, 17 Nov 2020 17:23:07 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:b622d996-4245-4dcc-a609-10990f5a133a</guid><dc:creator>Chris</dc:creator><description>&lt;p&gt;Try this out:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="csharp"&gt;a!localVariables(
  local!fieldA1,
  local!fieldA2,
  local!fieldB1,
  local!fieldB2,
  local!display: &amp;quot;Section A&amp;quot;,
  
  local!sectionAHasValidationError: or(
    rule!APN_isEmpty(local!fieldA1),
    rule!APN_isEmpty(local!fieldA2)
  ),
  local!sectionBHasValidationError: or(
    rule!APN_isEmpty(local!fieldB1),
    rule!APN_isEmpty(local!fieldB2)
  ),
  
  local!validations: reject(
    rule!APN_isEmpty,
    {
      if(local!sectionAHasValidationError,&amp;quot;Error in Section A&amp;quot;,null),
      if(local!sectionBHasValidationError,&amp;quot;Error in Section B&amp;quot;,null)
    }
  ),

  {
    /*top level section*/
    a!sectionLayout(
      label: &amp;quot;Validation Info&amp;quot;,
      validations: local!validations
    ),
    
    a!buttonArrayLayout(
      align: &amp;quot;START&amp;quot;,
      buttons: {
        a!buttonWidget(
          label: &amp;quot;Section A&amp;quot;,
          value: &amp;quot;Section A&amp;quot;,
          disabled: local!display=&amp;quot;Section A&amp;quot;,
          saveInto: local!display
        ),
        a!buttonWidget(
          label: &amp;quot;Section B&amp;quot;,
          value: &amp;quot;Section B&amp;quot;,
          disabled: local!display=&amp;quot;Section B&amp;quot;,
          saveInto: local!display
        )
      }
    ),

    a!sectionLayout(
      label: &amp;quot;Section A&amp;quot;,
      showWhen: local!display=&amp;quot;Section A&amp;quot;,
      contents: {
        a!textField(
          label: &amp;quot;Field A1&amp;quot;,
          value: local!fieldA1,
          saveInto: local!fieldA1,
          required: true
        ),
        a!textField(
          label: &amp;quot;Field A2&amp;quot;,
          value: local!fieldA2,
          saveInto: local!fieldA2,
          required: true
        )
      }
    ),
    a!sectionLayout(
      label: &amp;quot;Section B&amp;quot;,
      showWhen: local!display=&amp;quot;Section B&amp;quot;,
      contents: {
        a!textField(
          label: &amp;quot;Field B1&amp;quot;,
          value: local!fieldB1,
          saveInto: local!fieldB1,
          required: true
        ),
        a!textField(
          label: &amp;quot;Field B2&amp;quot;,
          value: local!fieldB2,
          saveInto: local!fieldB2,
          required: true
        )
      }
    )
  }
)&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to validate fields on hidden section?</title><link>https://community.appian.com/thread/77919?ContentTypeID=1</link><pubDate>Tue, 17 Nov 2020 17:12:00 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:281c130c-cad9-4a8f-8661-fb1b3b119657</guid><dc:creator>cedric02</dc:creator><description>&lt;p&gt;Oh ok, I see...&lt;/p&gt;
&lt;p&gt;The only piece I miss, is how to save the result of validations from fields-section to this top level section with this common local var.&lt;br /&gt;&lt;br /&gt;Would you have a little example please ?&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;a!localVariables(
	local!sectionAHasValidationError: null,
	
	// top level section
	a!sectionLayout(
		validations: local!sectionAHasValidationError
	),
	
	// section with error
	a!sectionLayout(
		fieldA,
		fieldB,
		validations: {
		  if(
			and(isnull(fieldA), isnull(fieldB)),
			a!validationMessage(
			  message: &amp;quot;You must enter either a phone number or an email address!&amp;quot;,
			  validateAfter: &amp;quot;SUBMIT&amp;quot;
			), /* How to save the validations to  local!sectionAHasValidationError ? */
			{}
		  )
		}
	)
)&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to validate fields on hidden section?</title><link>https://community.appian.com/thread/77915?ContentTypeID=1</link><pubDate>Tue, 17 Nov 2020 16:50:37 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:941b36de-e1eb-49a0-b855-f2dfdedefe60</guid><dc:creator>Mike Schmitt</dc:creator><description>&lt;p&gt;It would just be an extra section layout that always appears at the top of the current form (think of having an information overview header) which stays constant despite which tab the user clicks into.&amp;nbsp; There wouldn&amp;#39;t need to be a parent/child relationship (since you&amp;#39;re correct in that you can&amp;#39;t nest sections at any level).&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to validate fields on hidden section?</title><link>https://community.appian.com/thread/77914?ContentTypeID=1</link><pubDate>Tue, 17 Nov 2020 16:48:59 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:ac6f416c-fde4-4840-bf20-d4442e65deef</guid><dc:creator>cedric02</dc:creator><description>&lt;p&gt;but&amp;nbsp;how can you have a top level layoutSection ?&lt;br /&gt;(as a sectionLayout can not contain others layoutSection children)&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to validate fields on hidden section?</title><link>https://community.appian.com/thread/77913?ContentTypeID=1</link><pubDate>Tue, 17 Nov 2020 16:32:44 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:570abd97-0292-4377-93ba-2a0efbdc3340</guid><dc:creator>Mike Schmitt</dc:creator><description>&lt;p&gt;My first suggestion would be to have a common, informational, top-level section that shows up regardless of which &amp;quot;tab&amp;quot; your user is on.&lt;/p&gt;
&lt;p&gt;If not, the solution is still easy: you just duplicate the same validation code across all your sections.&amp;nbsp; Any given section will have a section-level validation showing i.e. &amp;quot;validation error(s) found in Section A&amp;quot;, which would be an array showing a similar message for any section(s) currently reading a validatione error (useful if you have very many).&amp;nbsp; The advantage here is that it&amp;#39;s not too hard to scale up to handle many sections - the only real up-front lift is coding the local variable determining the individual section&amp;#39;s error state, and even then all you&amp;#39;re really doing is duplicating the &amp;quot;validations&amp;quot; code from the individual components within that section.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to validate fields on hidden section?</title><link>https://community.appian.com/thread/77911?ContentTypeID=1</link><pubDate>Tue, 17 Nov 2020 16:26:55 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:582053b2-8881-45af-91bb-5cca84620ebf</guid><dc:creator>cedric02</dc:creator><description>&lt;p&gt;Yes but in that case,&amp;nbsp;if the sectionA is visible, and sectionB hidden (with some fields in error).&lt;/p&gt;
&lt;p&gt;I will still have my problem, the submit button will not&amp;nbsp;trigger the validation of the sectionB errors...&lt;br /&gt;Or maybe I&amp;#39;m missing something.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to validate fields on hidden section?</title><link>https://community.appian.com/thread/77910?ContentTypeID=1</link><pubDate>Tue, 17 Nov 2020 16:23:08 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:60795194-f76d-4680-8bb5-0429698cf517</guid><dc:creator>Mike Schmitt</dc:creator><description>&lt;p&gt;You&amp;#39;d need to put the validation in one of your SectionLayouts then.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to validate fields on hidden section?</title><link>https://community.appian.com/thread/77909?ContentTypeID=1</link><pubDate>Tue, 17 Nov 2020 16:15:00 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:2bb857a8-5cbb-45a1-8c3a-5973514d4bbe</guid><dc:creator>cedric02</dc:creator><description>&lt;p&gt;A last thing, how would you do what I need with a&amp;nbsp;&lt;span&gt;headerContentLayout?&lt;br /&gt;(we&amp;nbsp;have no formLayout&amp;nbsp;just a&amp;nbsp;headerContentLayout)&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;a href="https://docs.appian.com/suite/help/20.3/Header_Layout.html"&gt;docs.appian.com/.../Header_Layout.html&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to validate fields on hidden section?</title><link>https://community.appian.com/thread/77905?ContentTypeID=1</link><pubDate>Tue, 17 Nov 2020 15:36:52 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:79ce0c4c-80d2-4f4b-bd8f-342c1a6a3970</guid><dc:creator>cedric02</dc:creator><description>&lt;p&gt;Ok I understand, thank you Mike.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to validate fields on hidden section?</title><link>https://community.appian.com/thread/77904?ContentTypeID=1</link><pubDate>Tue, 17 Nov 2020 15:34:53 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:451573d6-1f9d-438a-a2ea-723e452c0d9a</guid><dc:creator>Mike Schmitt</dc:creator><description>[quote userid="50421" url="~/discussions/f/user-interface/19936/how-to-validate-fields-on-hidden-section/77902#77902"]using a formlayout is mandatory&amp;nbsp;in your example[/quote]
&lt;p&gt;For a process task, I&amp;#39;d suggest that using &lt;em&gt;a!formLayout&lt;/em&gt; is mandatory in general.&amp;nbsp; That&amp;#39;s not strictly true, I guess - you could just use a sectionLayout and manually created button layout... but why would you want to?&amp;nbsp; the FormLayout component just makes things easier.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to validate fields on hidden section?</title><link>https://community.appian.com/thread/77902?ContentTypeID=1</link><pubDate>Tue, 17 Nov 2020 15:31:28 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:3b6c8257-8e76-4466-99e1-c7faa2b46558</guid><dc:creator>cedric02</dc:creator><description>&lt;p&gt;ok, using a formlayout is mandatory&amp;nbsp;in your example.&lt;br /&gt;I was trying a solution without a&amp;nbsp;&lt;span&gt;formlayout.&amp;nbsp;&lt;/span&gt;&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to validate fields on hidden section?</title><link>https://community.appian.com/thread/77900?ContentTypeID=1</link><pubDate>Tue, 17 Nov 2020 15:23:41 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:9a3b34f6-84a9-4261-9009-ce86d9bd08bc</guid><dc:creator>Mike Schmitt</dc:creator><description>&lt;p&gt;You would set that and similar local variables in the top-level variable declaration of your form.&amp;nbsp; As I already mentioned, the variable will re-evaluate automatically when any of the other data it uses is changed (assuming you&amp;#39;re using &lt;em&gt;a!localVariables()&lt;/em&gt; under default settings).&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to validate fields on hidden section?</title><link>https://community.appian.com/thread/77898?ContentTypeID=1</link><pubDate>Tue, 17 Nov 2020 15:19:12 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:be9a5b9e-8232-47e9-b267-772a6a7e356b</guid><dc:creator>cedric02</dc:creator><description>&lt;p&gt;Thank you Mike for this idea (I was testing such a one),&lt;/p&gt;
&lt;p&gt;but how (where) do you set this var&amp;nbsp;&lt;strong&gt;&lt;em&gt;local!SectionAHasValidationError &lt;/em&gt;&lt;/strong&gt;&lt;em&gt;?&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;&lt;em&gt;In the SaveInto of each field?&amp;nbsp; (I have more than 30 fields)&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;&lt;em&gt;Can&amp;#39;t we do that once? &lt;/em&gt;&lt;/p&gt;
&lt;p&gt;&lt;em&gt;(I&amp;#39;ve tried to do it in the &amp;quot;validations&amp;quot; section, but how?&amp;nbsp; as &amp;quot;a!save&amp;quot; is forbidden)&lt;/em&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to validate fields on hidden section?</title><link>https://community.appian.com/thread/77897?ContentTypeID=1</link><pubDate>Tue, 17 Nov 2020 15:13:35 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:4f65608e-d6b5-4964-90d0-306511bf7a5a</guid><dc:creator>cedric02</dc:creator><description>&lt;p&gt;Thank you Pedro.&lt;br /&gt;Even if the formLyaout is the better way, I was looking for a solution&amp;nbsp;without it...&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to validate fields on hidden section?</title><link>https://community.appian.com/thread/77896?ContentTypeID=1</link><pubDate>Tue, 17 Nov 2020 15:05:23 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:45f5b97c-0cf0-4bb2-8b78-e7344c542d95</guid><dc:creator>Mike Schmitt</dc:creator><description>&lt;p&gt;It gets trickier to deal with when you need to do it this way, but after you&amp;#39;ve implemented it you&amp;#39;ll have a lot more power/control at least.&lt;/p&gt;
&lt;p&gt;First, you should keep track of the validity of each section (overall) in a local variable.&amp;nbsp; i.e. &lt;strong&gt;&lt;em&gt;local!SectionAHasValidationError&lt;/em&gt;&lt;/strong&gt;&lt;em&gt;&lt;/em&gt; (boolean), etc.&amp;nbsp; Utilizing &lt;em&gt;a!localVariables()&lt;/em&gt; under default settings, you should simply be able to evaluate the validity of your Section A fields with normal logic in the variable definition, and it would update itself anytime any of those values is changed.&lt;/p&gt;
&lt;p&gt;Then, as Pedro said above, add a Form Level validation which fires at the Submit event, which itself checks which (if any) of the Section X Validation Error variables is &amp;quot;true&amp;quot;, and perhaps advises the user which section has the error - they can then switch back to that section and see the particular validations on the fields themselves.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to validate fields on hidden section?</title><link>https://community.appian.com/thread/77895?ContentTypeID=1</link><pubDate>Tue, 17 Nov 2020 15:00:12 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:5c19c679-4816-424f-bb8e-31831914499e</guid><dc:creator>Pedro Sim&amp;#245;es</dc:creator><description>&lt;p&gt;Hi Cedric,&lt;/p&gt;
&lt;p&gt;Please consider handling the validation at form level upon submission. Check the below link&lt;/p&gt;
&lt;p&gt;&lt;a href="https://docs.appian.com/suite/help/20.3/Validation_Message.html"&gt;https://docs.appian.com/suite/help/20.3/Validation_Message.html&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Regards,&lt;/p&gt;
&lt;p&gt;Pedro&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>