Loading 2 REST Models at the same time is causing an Bad Request error

  • 1
  • Problem
  • Updated 2 years ago
  • In Progress
I have two REST models configured on a page. The first one merges in data from a Salesforce model to query the REST model. The second one uses a value from the first REST model to query data.

If I load the first one, and then manually query the second model using a table global action, I don't get an error. But if I have both configured to load on page load, and causes an error for both.

Any direction on this would be great.
Photo of Brayden Smith

Brayden Smith

  • 1,078 Points 1k badge 2x thumb

Posted 2 years ago

  • 1
Photo of Peter Kong

Peter Kong, Employee

  • 440 Points 250 badge 2x thumb
Hi Brayden,

What error are these Models causing?

At the moment I'm hypothesizing that the first Model not loading the required data from the second Model by the time the 2nd Model auto-queries. If that is indeed the case, I have some things in mind we could try out!

Regards,
Peter
(Edited)
Photo of Brayden Smith

Brayden Smith

  • 1,078 Points 1k badge 2x thumb
That is correct. The first model does not return data in enough time for the second model to use. What I've done as a workaround is inserted separate query actions for each model.

It would be ideal if I didn't have to do this, because it becomes pretty tedious trying to make sure I'm querying all the right models at the right time (based on when tab is first shown).
Photo of Peter Kong

Peter Kong, Employee

  • 440 Points 250 badge 2x thumb
Would you be comfortable doing some Javascripting? We do have methods for creating Skuid Events & triggers; one of the events, "models.loaded", triggers at the end of a successful query - I'm thinking we could leverage this to do the query automatically!
(Edited)
Photo of Peter Kong

Peter Kong, Employee

  • 440 Points 250 badge 2x thumb
Also alternatively, try doing this:

Make sure both Models do not Query on Page Load, and create a Global Action that "Runs Multiple Actions", and add the following Actions:
  1. Query Model1
  2. Query Model2
Let me know if that works without error... if not then we might have to resort to the Events.
(Edited)