Transformers values not available to JS query run on startup

I have a JS query that is running on startup.

The first part is this:

// First let's see if we have a Campaign Admin logged in
if (trIsAdminLoggedIn.value) {
  await qryCustomers.trigger()
  return
}

However trIsAdminLoggedIn.value is undefined at this stage of the lifecycle and referencing it is not calculating its value.

I have a a workaround. Put {{trIsAdminLoggedIn.value === undefined}} in the Disable query parameter in the Advanced tab. This delays its run until the transformer is ready to work.

Hey @bradlymathews! Is the query running at all?

Also curious what the transformer is calculating!

Yes the query is running, but console.log(trIsAdminLoggedIn.value) returns undefined.

trIsAdminLoggedIn is checking if a particular group is logged in

// trIsAdminLoggedIn
return {{current_user}}.groups.findIndex(el => el.name === "Campaign Admin") >= 0

Got it, alright, we have an existing bug report for the behavior of page load queries that reference transformers. I can let you know if there's an update there. In the meantime, would it be possible to have the logic run as part of the JS query instead?

You might be able to save the result to a temp state so that you can still reference it elsewhere in your app, the same way you would with a transformer.

That would be another good workaround, a little more visible than the one I picked, with a param "hidden" over in the Advanced tab, but also a little more complex.