Okay so I solved it in a much more seamless way. Here are the steps:
- on the button, in the DisplayMode field I have this code:
If(initialInfoForm.Valid, DisplayMode.Edit, DisplayMode.Disabled)
- I have code set in the Required field of the two data cards set Required to true if it is visible:
If('Temporary Datacard_1'.Visible, true, false)
Testing the code it behaves as required:
- when the two fields are NOT visible, they do not influence what the DisplayMode of the button will be
- when the two fields ARE visible, they are required to have values otherwise they will not be able to click the button!