If you think that something doesn't work in Aware IM post your message here
#51312 by BobK
Wed Aug 07, 2019 7:53 pm
I have a Required attribute with Type 'Yes/No' and an initial value of 'Yes' that uses the Switch widget.

If I move the Switch to 'OFF' I get the 'This field is required' error.

Using the Checkbox widget works as expected, but I would really like to use the Switch widget.

Anyone else experience this?

By the way, I am using the latest build (2628)
#51320 by PointsWell
Thu Aug 08, 2019 7:21 am
BobK wrote:I have a Required attribute with Type 'Yes/No' and an initial value of 'Yes' that uses the Switch widget.

If I move the Switch to 'OFF' I get the 'This field is required' error.

Using the Checkbox widget works as expected, but I would really like to use the Switch widget.

Anyone else experience this?

By the way, I am using the latest build (2628)


Logically how would you make a switch mandatory? It defaults to the Off position until you save the form and then that becomes No/Zero/Off (I think). The switch can't be in a NULL position, it is always in a default position so how would you test that it had been completed.
#51323 by BobK
Thu Aug 08, 2019 1:56 pm
Further testing using MySQL (if that matters)

Tested 4 fields, all with type 'Yes/No' and the Switch widget

Field1 is required with initial value of 'No'
Field2 is required with initial value of 'Yes'
Field3 is not required with no initial value
Field4 is required with no initial value

When creating a record, Field1 and Field4 receive 'This field is required' error
I can only create a record if Field1, Field2 and Field4 are all set to 'Yes'
PointsWell is correct, Field3 defaults to 'No' and i saved in the database as '0'.

When updating an existing record, changing Field1, Field2 or Field4 to 'No' receives the 'This field is required' error

Since it appears that a 'Yes/No' attribute using the Switch widget can never be null (as PointsWell pointed out) I can safely remove the 'Required' property.
On the other hand, since the field can never be null, even if it is required, I should never see the 'This field is required' error. But I do.
#51348 by rocketman
Sat Aug 10, 2019 11:34 am
AwareIM yes/no fields alway used to have 3 states (i'm on 8.1 so not sure if this is still relevant )
yes - 1
no - 0
and empty or null (nothing)

Just out of curiosity, could you try saving a new record whilst the state is ON then editing it and turning it OFF to see if it sticks

If it does, then a BO rule might help something like IF YESNOAttribute is UNDEFINED then YESNOAttribute='No'
#51350 by rocketman
Sat Aug 10, 2019 10:34 pm
“PointsWell is correct, Field3 defaults to 'No' and i saved in the database as '0'.”

Are you sure about this? Since the field is “not require” I’d bet it defaulted to null (empty) and you saved it as that
#51351 by PointsWell
Sat Aug 10, 2019 10:47 pm
rocketman wrote:“PointsWell is correct, Field3 defaults to 'No' and i saved in the database as '0'.”

Are you sure about this? Since the field is “not require” I’d bet it defaulted to null (empty) and you saved it as that


On BO creation it may be NULL. On save the switch when the it is in the No position then it saves as 0. The switch can only be on or off yes or no when the BO is saved, there is no third position. This is a binary field after all so programmatically it can only be 1 or 0 to maintain the binary concept, setting it to NULL indicates that the options you are trying to capture are not in fact binary.

If you are creating the BO by process and never show the form you can circumvent this and it will save as NULL if you don't have a default value and your process doesn't set the value. You might be able to get the checkbox to not save as 0 but it it does I'd say that is a bug - I haven't tested and tend not to use checkboxes in my binary choices.

Given the behaviour and applying some logic the required flag seems to be covering those instances such as "I have read the T&Cs" where you must insist that the field is checked before progressing. It is fairly difficult to see how else to implement required value with a field that is yes or no (the NULL being only a temporary state existing only when an object is not used via the UI and not possible to return to with the UI without a process to remove the value)
#51352 by rocketman
Sun Aug 11, 2019 11:38 am
Pointswell - you're right, my apologies. I made a small BSV and tested. Curious as to why AIM should consider 0 (No) as not fulfilling the "Required" requirement . Anyway, as long as an initial value is set to something and the "Required" is left unchecked, BobK will achieve his desired result

With your logic requirements, I have a similar requirement for T's and C's. I set the initial value to "No" and then put a rule in place IF NOT(YESNOattribute='Yes') then REPORT ERROR 'You have not indicated that you have read the T's And C's

In the UK, we are not allowed to set the defaults to 'Yes'
#51353 by PointsWell
Sun Aug 11, 2019 12:15 pm
rocketman wrote:Curious as to why AIM should consider 0 (No) as not fulfilling the "Required" requirement .


Because if you conform to binary being either 1 or 0 (ie you have correctly given the field an initial value) then which answer is the field in a "completed" state? It can only be 1/yes.
#51354 by rocketman
Sun Aug 11, 2019 2:36 pm
Not that it makes the slightest bit of difference here but I don't agree with you last argument. If I have an attribute with a choice list which is set as "required", I would expect the "required" to be fulfilled if any one item in the choice list is entered. A binary field should be no different - it is a choice list of yes or no and either option should fulfil the "required" option.

The "Required" option on a binary is however superfluous since it cannot be empty
#51355 by BobK
Mon Aug 12, 2019 2:11 pm
Even more testing:

I changed the widget for all 4 of my test attributes from Switch to CheckBox and retested.

Just like my testing using the Switch widget:
Field1 is required with initial value of 'No'
Field2 is required with initial value of 'Yes'
Field3 is not required with no initial value
Field4 is required with no initial value

When creating a record, I do not get any errors and Field2 is saved in the DB as '1' (Yes/On) and all the other fields are saved in the DB as '0' (No/Off)
I can update all the fields to Yes and save with no errors and update all the fields to No and save with no problems.
I only get the "Required" error when using the Switch widget and the attribute is set to Required and has a value of 'Off'


I agree with rocketman's final statements:

Not that it makes the slightest bit of difference here but I don't agree with you last argument. If I have an attribute with a choice list which is set as "required", I would expect the "required" to be fulfilled if any one item in the choice list is entered. A binary field should be no different - it is a choice list of yes or no and either option should fulfil the "required" option.

The "Required" option on a binary is however superfluous since it cannot be empty


And to set the record straight, I have un-checked the Required option for all my Yes/No attributes.

Who is online

Users browsing this forum: No registered users and 7 guests