I want to give the user a checkbox to override required fields. For instance, if its an emergency software install I don't want the user to select a scheduled release date.
If that's not possible, is there a way to dynically change the form field label color?
Right now to solve this problem I have a script that generates error message based on the field logic. For instance, if override is not selected the user must fill in a date value. If they don't my script pushes out an error on the form. I have pre-colored the text to red, but, if the user fills out the form the label is still red.
You could make the required fields dependent on the check box field, that if they select override as one of the check boxes that the required fields change to the selection of Overidden if they are selection fields, if they are text fields then this wouldn't help but if they are selection this would be the easiest route to consider.
Regards,
Joe
If you are running SBM, you can add a form to the workflow and use javascript to control the fields.
For example here's a snippet that displays a field called 'RFC' if the priority is 'Critical'. Otherwise the field is optional and hidden.
function priorityChanged() {
var text = GetFieldValue("PRIORITY");
if (text == "1 - Critical") {
ShowField("RFC");
MakeFieldRequired("RFC");
} else {
MakeFieldOptional("RFC");
HideField("RFC");
}
}
Thanks for your help, that's great to know. I'll give it a try.
Created the same fields as in your script, but now I'm not entirely sure where to place the code. I've tried a few things, like adding/importing the javascript to the form.
I'm not a javascript guru.
When I display the form the javascript is not invoked. Am I missing something? How is the function invoked?
You also need to tell the form when to invoke that function.
In this example you'll want the function to be called when the PRIORITY file is changed. So, add this to the javascript file:
AddChangeCallback('PRIORITY', priorityChanged);
You'll also want to execute the function when the page is loaded, so you'll also add:
AddLoadCallback(priorityChanged);
The SBM Composer Guide has a section on the available javascript functions.
Wow, it works!
I had just found the appanedix but your example did the trick. Thanks for giving me the little push to help me over the top!
What am I doing wrong now? I'm trying to hide and display a field based on a checkbox on a binary/Trinary field. It's hiding the field by default but when I check the field it does not make the field appear.