Code within lookup control ready method (fd.control().ready) not executing

Hello, I’m trying to get information from a lookup control in a Display form once the form and field are rendered. After troubleshooting, it looks like the field never reports itself as ready; even a simple console.log doesn’t work. Here’s the code I’m using:

fd.spRendered(() => {
  // logs "Form is rendered" every time
  console.log("Form is rendered");

  // logs as null as expected since the field isn't ready
  console.log(fd.control("LookupField").value);
 
  fd.control("LookupField").ready(() => {
    // never logs an output
    console.log("Control is rendered");
  });
});

When I make fd available in the console and query the control after the form is fully loaded, the _isReady value stays set to false.

image

Am I missing something?

Hello @jnordman,

This is a bug on our side. The ready event is not triggered for the control when it is in read-only mode. I will let you know as soon as the fix is published.

In the meantime, you can add a timeout before retrieving the control's value:

fd.spRendered(function() {
    setTimeout(() => {
        console.log(fd.control('Lookup3').value.LookupValue);
    }, 5000);
});
1 Like

Awesome, thank you! This works well for now, and cutting the timeout down to as low as 500ms doesn’t seem to cause issues.

1 Like