Changing field behaviour dynamically
This one has come up a few times recently. Some people have made hacks in client scripts, some have just used supported client scripts, and some have tried and just got it wrong.
This example shows how you can appear to change the usage of a field from, say, required to optional, using no client scripting and just local variables. Basically you have two local variables, tow fields, one set to required and one to optional, and show one or t'other. You then need to assign the real (process) variable on save. You also need to fill the local variables on load, of course.
In this example I have also added the optional step of assigning the process variable, and the 'other' local variable on field exit. I was intending this to be the only code, but you will find that the 'when changed' event does not fire when you are in the field and you press submit. This is a bug, I believe. In any case, it demonstrates how you can switch between them during an action.
If this is not required, the fields do not need to be set to 'has dependants' and the 'on changed' scripts may be removed.
Download the solution here: