Hide fields conditionally

Hi,
SuiteCRM 7.11.4
I’m trying to hide fields conditionally. I am, however, a kludge artist and ineffectual code monkey, so have likely got something terribly wrong.

I’m attempting to follow the instructions HERE with a side-order of THIS TUTORIAL, please laugh at me all you want.
So, in /custom/modules/Contacts/metadata/detailviewdefs.php It has

   array (
          'file' => 'modules/Contacts/Contact.js',
          'file' => 'custom/modules/Contacts/hideminister.js',

The file /custom/modules/Contacts/hideminister.js reads as follows

(function(){
  if ($("#roll_c").val() = "0") {
    $("#LBL_MIN_NOTES").hide();
    $("#min_notes_c").closest("td").hide();
	$("#LBL_MINSTREAM").hide();
    $("#minstream_c").closest("td").hide();
	$("#LBL_ORDINATION").hide();
    $("#ordination_c").closest("td").hide();
	$("#LBL_ROLL").hide();
    $("#roll_c").closest("td").hide();
	$("#LBL_CERTOFGS").hide();
    $("#certofgs_c").closest("td").hide();
	$("#LBL_STUDYLEAVEACCRUED").hide();
    $("#studyleaveaccrued_c").closest("td").hide();
	$("#LBL_STUDYLEAVEUSED").hide();
    $("#studyleaveused_c").closest("td").hide();
	$("#LBL_EMERITUS").hide();
    $("#emeritus_c").closest("td").hide();
	$("#LBL_ORM").hide();
    $("#orm_c").closest("td").hide();
   }else{
    $("#LBL_MIN_NOTES").show();
    $("#min_notes_c").closest("td").show();
	$("#LBL_MINSTREAM").show();
    $("#minstream_c").closest("td").show();
	$("#LBL_ORDINATION").show();
    $("#ordination_c").closest("td").show();
	$("#LBL_ROLL").show();
    $("#roll_c").closest("td").show();
	$("#LBL_CERTOFGS").show();
    $("#certofgs_c").closest("td").show();
	$("#LBL_STUDYLEAVEACCRUED").show();
    $("#studyleaveaccrued_c").closest("td").show();
	$("#LBL_STUDYLEAVEUSED").show();
    $("#studyleaveused_c").closest("td").show();
	$("#LBL_EMERITUS").show();
    $("#emeritus_c").closest("td").show();
	$("#LBL_ORM").show();
    $("#orm_c").closest("td").show();
   })();

Any advice on what I have seriously screwed up (or how I can figure out why it isn’t doing anything) would be much appreciated.

Start with a simple js function, with only an alert. Check if it is getting loaded into your page (you should see it in the page source).

You might need some Javascript rebuild from Admin / Repairs

1 Like