While I am not a javascript programmer, I can usually read through simple javascript code and understand what is happening. I am trying to write a simple script to show or hide a link to form field based on the value of a checkbox. Unfortunately it does not seem to be working even though it runs clean in the console log. Is there any quirky bugs in relation to scripts and link to form fields. I have included my simple script for reference. Thank you in advance for any assistance you can provide, it is greatly appreciated.
function New_Script() {
// get the check box id
var the_check_box = ‘fld-25afad2179224c368867d5f688afe496’;
// get value of check box – checked or not
var checked = record.getFieldValue(the_check_box_id);
// get id of the link to form field
var bills_id = ‘fld-3af9c9d4356a4dbba70d1e09a6ef6db5’;
// check if the check box is checked or not
if (checked == true) {
// true condition;
console.log (“show bills”)
bills_id.hideField = false;
} else {
// false condition;
console.log (“hide bills”)
bills_id.hideField = true;
}
}
New_Script();
Update:
hideField
is a parameter to the field object and not to a fieldId:
var field = form.getFieldWithId(fieldID);
field.hideField = true;
Original response:
Two things come to mind looking at the script:
- you might need to run
document.saveAllChanges();
at the end of the script
- sometimes changes done by a script are not directly visible in the GUI, you might need to refresh the record by pressing cmd-r or clicking on the ‘recalculate formulas’ button.