Entering data in A or B fields on a View

Userlevel 3
Badge +13

I have a view setup with 5 fields as follows:


Please fill in either A or B


A. Surname              B. Alt ID

A. Forename           B. Reference



Users must either fill in all three A fields """OR"""" all two B fields, how can I set this up with rules?


I tried "required" on the smartobject holidng the fields, but that is no good because it expects there to be a value or said field (when it might not be applicable if the user picks the other options), and does not take into account the """OR""" rule.


Is there a way if the users inputs all of the A fields (and checks to make sure they do) and prevent the users entering anything in the B fields? and vice versa? This rule must be dynamic so also allows the rule to reset if the user deletes any filled in data.


Can't quite work out how to achieve this.

Any ideas K2ers?





27 replies

One thing that comes to mind is a radio button to select group A or group B.  Something that you could do is if group A is selected, you can disable the fields/controls on group B and they won't be validated against...and in turn if B is selected, then disable the controls on group A.  


To sum up: I would go with a radio button with a conditional validation against all of the  controls.  If the controls are disabled, they don't get validated on.


Let me know if you need calification or would like to see more.  I can build it out on my end.



Userlevel 3
Badge +13

Hi Dave,


Thanks for your suggestion, didn't think of that.


In a slight twist, instead of using radio buttons, say for example someone starts filling in a field from the A side (could be any of the 3), can we disable the B side fields (2 fields)? But if then if the user changes there mind, they delete the data from the A side fields, all A and B fields are available? And then the same idea if the user starts with the B side?


As this form is intended for students, I want to make it as smooth as possible without requiring many clicks.


Could you possible expand on this and see if its doable on the fly?

It is possible to do this without the radio buttons.  You'd just need to create a rule on the text boxes (on change) to disable the opposite group controls.  


I would possibly define the Group A and Group B controls as something like Primary and Alternate, then it might be easier for a user to identify with the data they are entering.  I built this out on a test view...let me know if this opens up any possibilities for you.


Userlevel 3
Badge +13

Hi Dave,


Will have a look at this shortly, your example got me thinking....(i know it doesn't happen that often), but instead of disabling the opposite group, how about it just clears it (or is that what disable/enable does? So when any data is entered in Group A, Group B is emptied, and if someone starts typing in Group B, Group A gets emptied? That way, no clear button is needed, but its obvious to the user only one group of info is allowed?

You might be able to change the rule on any of the Group A controls to transfer a " " blank space or a NULL to the opposite controls on the control change event.  I tend to have more control when I fire a global event like (clear) to the adds a lot of rules when you enable multiple transfers.

Userlevel 3
Badge +13

Hi David,


Users have moved the goalposts, instead of disabling the alternate group, they want them cleared as soon as you click on the other group and vice versa.



I've used the below rule to clear the expressions back to NULL (used Empty String expression) for the 3 fields, but it only changes them AFTER i've entered data into the Student Number(1) field and clicked OFF it...


Is there anyway to get it to clear the 3 fields as soon as i click ON the Student Number(1) field?


I was wondering if there is an event called if a textbox is clicked rather than changed (which seems after the event)



I was about ready to say that there is no property for this (the control only has onchange), however there might be a way to have a datalable dectect that there are changes happening to the text box.  


Give me a minute to experiment.

I tried a couple variations on transfering data to a datalable, and it requires that you come out of the text box to detect or fire the onchange event.


Without extra buttons on the screen, you'd have to swap out the text boxes with something like a name picker or lookup control so that the onchange can fire from within the confines of the control itself.

Userlevel 3
Badge +13

Hi Dave,


Think you're right, only way is with buttons...


So what i've done is added 2 Radio Buttons, I want Radio Button 1 to be the default and be pressed (Green), any idea how i do this? I've tried enabled and visible properties but no joy. If I can get it to default to Radio Button One when it loads, then I can do some disabling and clearing of data.


At the moment, both Radio buttons are unselected when i run the View, if I could have Radio Button 1 selected, then at least the user know which side has been selected.


Thanks again for your on going help and patience

You'll have to modify the initialization rule to transfer data to the radio button that you want to have the ball.




When view is initialized > Transfer Data (configure) > Send the name of the first radio button to the control.


Userlevel 3
Badge +13

I'm using 2 seperate Radio buttons, not a radio button list.

Just need the first button to be pressed on initialiation of the view.

If this is part of the new control package...I'm still on smartform 1.0.5., so I haven't seen some of the newer controls.


It should still be a simple transfer to the button on view initialize.  Can you send a screen shot?

Userlevel 3
Badge +13

Here is the View with the two radio buttons:


Here is the rule:




Create or modify the On view initialize rule to add "Transfer Data" to the Radio Button text box.  In the configure just add the below info to have Radio Button be the one that is already clicked:

One thing to consider is that with a radio button list, it will toggle the button back and forth.  I'm not sure if your view requires that you have two seperate radio buttons.

Userlevel 3
Badge +13

Hi Dave,


As per the screenshot, I already have the Event "When the View executed Initialize" then transfer data:


I did configure and added Radio button A control to Radio Button. But then i run the view, nothing happens, both radio buttons are still unselected.


Ok, I see what's up.


Your dragging the radio button to the field.  


You have to type out the actual name: Radio Button

Userlevel 3
Badge +13

Tried that as well, but still no joy:


When the View execited Initiaize

then transfer data (configure)



Sorry this this taking so should be fairly simple.  I'll show you how I enable buttons or check boxes on my end and hopefully we can figure out what's happening.  I'm not on current SmartForms, so I have to use the Radio Button List control:


I created a radio button with one static value of Radio Button


On view Initialize I enable a transfer rule and configure it by typing in the exact phrase from the above List Items box: Radio Button


On my end when I just run this view, I get the radio button selected:


Userlevel 3
Badge +13

I ditched the Radio button and used your Radio Button list and that worked :-)


Will create another Radio button list and have a play with using both Button Control Lists to enable and disbale each other...


Thanks Dave, you deserve a beer for helping!!!


Yea, I'll need to upgrade to start testing out some of those newer controls.


Good luck with the form.

Userlevel 3
Badge +13

P.S. Just tried having two "seperate" button lists, but that means you can select both buttons at the same time, can the transfer data also unselect a a radio button? so if i select radio button 2, unselect button 1?

I would just modify the radio button list control with both of your Static Values.  That way you will toggle between both values instead of dealing with another control and having to fire more rules.


If you need to play with the look of the control, I generally like to select the horizontal property.

Userlevel 3
Badge +13

Hi Dave,


I found a control called Radio Button Group, this has allowed me to link the two individual Radio Buttons together and allows toggle. I then set the View rule to transfer data Radio Button on Initialize (see below): This works great when you run the View as Button B is selected.


Problem is, if I then run the "Form" with this view added, is does not do the above, any idea why? I tried setting up the same rule on the Form to see if that would work, but it just leaves both radio buttons unselected....


Userlevel 3
Badge +13

Managed to get it working, moved all the rules to the form including the Radio buttons and bingo working. Just thought i'd post so anyone else reading knows how solved it.


All credit to Dave for pointing me in the right direction

Badge +7

Hi SharpSharp and Daerne


I managed to created your required outcome with a radio button list wich when clicked one one of the option only certain fields and labels are displayed and when clicked on the other radio button, those fields and labels are hidden and disabled and others are displayed, I think this is a realy simplified way of doing what you desire.


I read throught your posts and saw that it looks like you managed to get it working as you wanted by using radiobutton groups. I wanted to make a suggestion, that you have a look at the solution that i have attached to this post as i said i think it would be more simplified.


Please use Package and Deployment to deploy the single view package to your enviroment.


Kind Regards