Skip to main content
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 

}


The purpose of this code is to render custom field Case.Order_Number__c when any child experience has custom field Experience.Order_Number_Show__c set to true.

Please advise

Hey Brandon -

I believe the issue with the snippet is here:


// Get the experiences child relationship if (caseModel.getFieldValue(caseRow, CHILD_RELATIONSHIP_NAME)) { experiences = caseModel.getFieldValue(caseRow, CHILD_RELATIONSHIP_NAME).records;  }


Update the if statement to check to see if there’s child records in the row with the following code instead:


// Get the experiences child relationship if (caseModel.getFieldValue(caseRow, CHILD_RELATIONSHIP_NAME) !== undefined) { experiences = caseModel.getFieldValue(caseRow, CHILD_RELATIONSHIP_NAME).records; }


Thanks!
Christine


Reply