Wait for multilookup ready inside fd.beforeRendered

Greetings,

I have to implement some logic(i.e. hide all form fields) based on the value of a multilookup field.
The problem is that the ready event for the lookup is asynchronous while the form event is synchronous.
Is this possible?
One option would be to do the logic inside the ready event but then for a small amount of time the fields could be visible and I don't want that...

Many thanks,
Adrian

Dear @Adrian_Ganea,
Why not hide all fields by default, and then show them if the value is not equal to what you're checking for? This way, the fields will be hidden to begin with, and only appear after the field value has been checked.

True, thanks!

Any chance that the ready event for the multiselect field has a bug on slow connections when the form is complex? I have noticed instances when value.length returns 0, when in fact the field has some values set.
I am thinking of asking for the field's value using a separate rest request, rather than relying on the ready event..

Dear @Adrian_Ganea ,
Well, the second option would always work, but if there's indeed a bug - we need to replicate it in order to fix it. If you could share your code - that would be good!

Even better if you can consistently replicate the issue, and give us access to the specific form, that would be very helpful! If so, please, write us to support@plumsail.com (don't send an invite straight away, just information about the issue and link to this community post would be enough).

Thanks, I went with the separate request option.
The problem is I can't replicate the issue constantly and for now the workaround does the job.

Many thanks,
Adrian

Dear @Adrian_Ganea,
I believe the issue is that you've tried fd.beforeRendered, correct? Could you share the code that you were using before, so we could see if it was a bug or an expected behavior?

The following should work, for example:

fd.spRendered(function(){
  fd.field('MultiLookup').ready().then(function(field) {
    console.log(field.value.length);
  });
});

Thanks, but unfortunately I used the same code as you(and inside sprendered). Like I said, more often than not, the form works properly, but sometimes, when the connection is poor (e.g. when accessing the form via vpn for an on-prem sharepoint 2019) it is evident that the form loads slower(you can see the animated gifs of the multiselect spinning) and the code inside the ready event returns 0.

I will try to make a screen recording and post it here if needed.

Much appreciated,
Adrian

Dear @Adrian_Ganea,
If possible - please, do! That would be very helpful.