Code snippet to render a field if any child record of custom object has a value of true in a custom

I created the snippet and attached it to the Case Order_Number. I set field renderer to this javascript under “Custom (run a Snippet)”

The page loads, however order number is showing when it shouldn’t. No experiences have a true “Order_Number_Show__c” .

var CHILD\_RELATIONSHIP\_NAME = 'Experiences\_\_r', // Replace with the name of your child relationship Order\_Number\_Show\_\_c; // Replace with the name of the field on the child relationship you want to reference var field = arguments[0], value = arguments[1], $ = skuid.$, caseModel = field.model, caseRow = field.row, experiences = []; // Get the experiences child relationship if (caseModel.getFieldValue(caseRow, CHILD\_RELATIONSHIP\_NAME)) { experiences = caseModel.getFieldValue(caseRow, CHILD\_RELATIONSHIP\_NAME).records; } // Loop through child records; check if the "Show Order Number" field is true for any of them var showOrderNumber = false; if (experiences.length \> 0) { $.each(experiences, function(i, record) { if (record.Order\_Number\_Show\_\_c === true) { showOrderNumber = true; } }); } if (showOrderNumber === true) { // Run the standard field renderer skuid.ui.fieldRenderers[field.metadata.displaytype][field.mode](field,value); } else { // Do nothing }