Validating a field on submit

I have a component that contains user picker field which is a required field. This component also has a submit button. Something like the code snippet below.

{



a!pickerFieldUsers(
label: "Request Owner",
maxSelections: 1,
groupFilter: cons!EEP_GRP_ESTIMATORS,
value: property(ri!request, "cdo_owner", null),
saveInto: ri!request.cdo_owner,
required: true,
showWhen: ri!request.status_id_fk <> cons!EEP_VAL_STATUS_COMPLETE
),



a!buttonArrayLayout(
buttons: {
a!buttonWidget(
label: " Submit for Review",
icon: "arrow-right",
saveInto: {
a!save(
ri!request.status_id_fk,
cons!EEP_VAL_STATUS_IN_REVIEW
),
rule!EEP_UT_saveAuditData(
createdBy: ri!request.created_by,
createdOn: ri!request.created_on,
lastModifiedOn: ri!request.last_modified_on,
lastModifiedBy: ri!request.last_modified_by
),
/*Save Audit History Data*/
{
a!save(
ri!auditHistoryUpdate.estimation_id,
ri!estimation.id_pk
),
a!save(
ri!auditHistoryUpdate.event_timestamp,
now()
),
a!save(
ri!auditHistoryUpdate.initiator_name,
loggedInUser()
)
},
a!save(ri!estimation.total_cost, ri!totalCost),
a!save(
ri!EEPdocumentsToAdd,
a!forEach(
items: ri!documentsToAdd,
expression: 'type!{urn:com:appian:types:EEP}EEP_documents'(
document_id: fv!item,
object_type_id_fk: cons!EEP_VAL_TYPE_ESTIMATION_ID
)
)
),
a!save(
ri!breakdownsToDelete,
{
rule!EEP_UT_getBreakdownsToDelete(
estimationBreakdown: ri!estimationModNew,
estimationGroup: ri!estimationGroupMod
),

a!save(ri!commentToAdd.created_on, now())
}
)
},
submit: true,
style: "PRIMARY"

}

),



}

Now, I'm calling this component inside a foreach loop in the parent form.

foreach(

items: myLocalVariable,

expression: rule!myExpressionRule(fv!item)

)

The problem is that if the field is blank in any of the loops then triggers the validation when the button on a different loop is pressed, in other words I have to populated the field for all instances of the loop before I can click a button. Is there a way to get around this and only trigger the validation only for the button/picker field I'm selecting?

  Discussion posts and replies are publicly visible

Parents
  • 0
    Certified Lead Developer

    What do you hope to accomplish in using a repeating list of pickers and buttons, where all buttons submit the form?  Because the form will still be submitted regardless of which of those buttons you click.  Why wouldn't you have the individual fields save into a list, and then have the user submit the form based on a single submit button when you've determined through on-form logic that a sufficient number of picker fields have been populated?

  • Mike, the goal is that there is a list of items, but the user can only approve one of them at a time. The following screenshot shows what the interface looks like.

      

  • 0
    Certified Lead Developer
    in reply to Jose H.

    I suppose you could use ValidationGroup settings on your fields and buttons... just make each ValidationGroup unique per your current location in the array you're using to generate the repeated section.  I've traditionally avoided validationGroup on buttons since it works a little clunkily (such as, the "required" asterisks are no longer shown when a field has a validationGroup), but it would probably work here.  If you can't forego the "required" asterisks, my main alternative suggestion would be to simply disable the button in a particular section unless the required fields are filled.  Then you just set the "validate" parameter of the button to FALSE.

Reply
  • 0
    Certified Lead Developer
    in reply to Jose H.

    I suppose you could use ValidationGroup settings on your fields and buttons... just make each ValidationGroup unique per your current location in the array you're using to generate the repeated section.  I've traditionally avoided validationGroup on buttons since it works a little clunkily (such as, the "required" asterisks are no longer shown when a field has a validationGroup), but it would probably work here.  If you can't forego the "required" asterisks, my main alternative suggestion would be to simply disable the button in a particular section unless the required fields are filled.  Then you just set the "validate" parameter of the button to FALSE.

Children
No Data