Trying to show the values of a field based on the value of a connected object’s field.
Knack allows you to place the connected field on the details page, but doesn’t allow you to reference the field in “display rules”. Basically I want to show a field value for a field if connected object/field value is “NO”
I’ve been using OpenAI to assist with scripts and it does a pretty code job for me, however I can’t figure out the below code. Connected field is located in Table “Accounts” and is “field 380”. Field I want to show or hide based on connected field 380’s value is field_144 on view_287. Any and all help is appreciated… JON
HERE’S OPENAI’S CODE:
// Wait for the page to finish loading
document.addEventListener(“DOMContentLoaded”, function() {
// Get the connection field element within the view_287 container
var connectionField = document.querySelector(“#view_287 [data-field-key=‘field_380’]”);
// Get the field element you want to show
var fieldToShow = document.getElementById(“.field_144”);
// Show the field if the connection field value is “NO”
if (connectionField && connectionField.textContent.trim() === “NO”) {
fieldToShow.style.display = “block”;
} else {
fieldToShow.style.display = “none”;
}
});