Conditionally hiding fields and controls on Display Form and PDF

On a Display form, I have several SharePoint fields and controls in a grid where class is .my-section

I want to hide this entire grid based on the numeric value of a calculated SharePoint field (if the value is >=75, hide it all).

Current code within fd.spRendered:

function showHideMySection(){
//set variable to get the calculated field value
var vProbabilityCalc = fd.field('Probability_Total').value;
/hide the grid segment if score is at or above 75
if (vProbabilityCalc >= 75){
$('.my-section').hide();
}
}

This is my latest round after several attempts based on articles and documentation examples, but it was the one I thought should finally work. I've also tried applying a simple if statement directly to a single field without any luck.

I am very new to this. Suggestions?

Hi @kmayhew,

Your code seems spot-on, except for this line:

/hide the grid segment if score is at or above 75

It should have two slashes:

//hide the grid segment if score is at or above 75

If changing this line doesn't help, please share screenshots of the browser's console (F12). There should be some useful errors.

I fixed the comment mark, thank you!

Also - it appears that what I was missing was:

// Call the function to execute it
showHideWorthiness();

Rookie mistake, I'm sure!

Note: I also had to make the spRendered top line an arrow function (also new to me):

fd.spRendered(() => {