Hide multiple fields based on custom field value
Problem
Some fields are needed on the screen only when another field has a certain value. Keeping the fields visible on the screen when they are not needed creates clutter and may cause users to enter information in the wrong place.
Solution
You can solve this problem using Power Scripts™ Live Fields. The scripts will get the value of a customized and based on that value it will conditionally show or hide other fields.
liveField.sil
This is the main script that will be used in the Live Fields configuration. This script will call the second script, hook.sil.
lfInstantHook({"customfield_XXXXX"}, "hook.sil");
lfWatch("customfield_XXXXX", {"customfield_XXXXX"}, "hook.sil");
hook.sil
This script is not used in the configuration but instead is triggered by the main script.
if(argv["customfield_xxxx"] == "ABC") {
lfHide("customfield_1111");
lfHide("customfield_2222");
lfHide("customfield_3333");
} else {
lfShow("customfield_1111");
lfShow("customfield_2222");
lfShow("customfield_3333");
}
if(argv["customfield_xxxx"] == "XYZ") {
lfHide("customfield_4444");
lfHide("customfield_5555");
lfHide("customfield_6666");
} else {
lfShow("customfield_4444");
lfShow("customfield_5555");
lfShow("customfield_6666");
}
Important Information
Other custom fields can be added inside the logic statements as needed
Multiple “trigger” fields can be used to create the conditions that show or hide other custom fields
This script does not hide any custom fields by default. However, this can easily be added by copying the lfShow() functions and pasting them at the top of the script.