Hey Guys,
I have a database table that contains teams that have applied to the competition. I want to check the validation, if I insert team and competition to apply that already exists in the table displays as "Already applied.
a!formLayout( label: "Apply Team to Competition", contents: { a!sectionLayout( label: "", contents: { a!columnsLayout( columns: { a!columnLayout( contents: { a!pickerFieldRecords( label: "Choose a Team", recordType: 'recordType!{9590f767-061f-48ac-850e-63e14f7db91d}SGDC Dance Team', value: ri!map.teamId, saveInto: ri!map.teamId, showRecordLinks: false, maxSelections: 1, required: true ) } ), a!columnLayout( contents: { a!pickerFieldRecords( label: "Choose a Competition", recordType: 'recordType!{fa469098-7d29-4880-bf7d-18b43769b332}SGDC Dance Competition', value: ri!map.compId, saveInto: ri!map.compId, showRecordLinks: false, maxSelections: 1, required: true, validations: "" ) } ) } ) } ) }, buttons: a!buttonLayout( primaryButtons: { a!buttonWidget( label: "Apply", saveInto: {}, submit: true, style: "PRIMARY", validate: true ) }, secondaryButtons: { a!buttonWidget( label: "Cancel", value: true, saveInto: ri!cancel, submit: true, style: "NORMAL", validate: false ) } ) )
Discussion posts and replies are publicly visible
As best as I can guess you're saying if the user selects both a team and a competition from the picker fields, but that team/competition already exists in the DB, then it displays a validation error.
In this case you'd pick one of the two picker fields to add validation to (you could do the same in both but it would be a bit redundant); the best might be your "Competition" field as users would usually fill in the later field second.
In your validation you would:
This is usually written like:
validations: { if( or( a!isNullOrEmpty(ri!map.compId), a!isNullOrEmpty(ri!map.teamId) ), {}, if( /* for this example the following hypothetical rule returns true/false values, however you could simply use a query entity rule that returns a TotalCount and check that it's > 0, etc. */ rule!queryRule_CheckingTeamRegistration( compId: ri!map.compId, teamId: ri!map.teamId ), "Selected Team is already registered for Selected Competition", {} ) ) }
Thank you!!