Set read only state on a secondary list.
NOTE: This functionality is only available in GlobalSearch Go
Component states may change if GlobalSearch Go needs to redraw dynamic controls. If you need to lock a dynamic list, the script below can poll for the state and set it correctly.
const interval = setInterval(() => {
if(!$$inject.fieldProperties['Secondary'].readOnly){
$$inject.fieldProperties['Secondary'].readOnly = true;
console.log("Secondary field set to read-only.");
}
console.log("Polling Secondary field read-only status...");
}, 500);
setTimeout(() => {
clearInterval(interval);
console.log("Secondary field poll stopped.");
}, 5000);
return 'Loaded';
🔍 Line-by-Line Breakdown
1. Start a Repeating Check
javascript
const interval = setInterval(() => {
if(!$$inject.fieldProperties['Secondary'].readOnly){
$$inject.fieldProperties['Secondary'].readOnly = true;
console.log("Secondary field set to read-only.");
}
console.log("Polling Secondary field read-only status...");
}, 500);
This sets up a loop that runs every 500 milliseconds (half a second). Each time it runs:
It checks if the Secondary field is still editable.
If it is, it locks it and prints a message.
It also prints a message saying it's checking.
Think of it like a security guard walking by every half second saying, “Is this door locked? No? Let me lock it.”
2. Stop the Loop After 5 Seconds
javascript
setTimeout(() => {
clearInterval(interval);
console.log("Secondary field poll stopped.");
}, 5000);
This sets a timer to stop the security guard after 5 seconds. It’s like saying: “After 10 checks, you can go home.”
3. Return a Status Message
javascript
return 'Loaded';
This just returns a message saying the script has finished loading to the Live Field.