Issue with re-querying model after changes to separate model

  • 1
  • Problem
  • Updated 3 years ago
I'm currently building in a workflow to check for duplicates before converting a lead.  To do so, I have a duplicate leads model whose conditions compare fields like email address to the same fields on my Lead model.  When duplicates are identified, they are presented in a table along with a separate table containing values from the current Lead record for comparison.  Both can be edited in-line to clear up any errors that might be causing the duplicates to be identified.  I then have a custom Save button that saves and re-queries both models.

When editing and saving the duplicate record in-line, the process works perfectly.  The value is updated, the models re-queried, and the tables disappear from the page (they're conditionally displayed only if the duplicate model contains any rows).  However, when the current Lead is edited in-line, the models are saved correctly, but the query does not seem to update the Duplicate Leads model, as this continues to be displayed in the pop-up, despite the fact that the model should now return no rows based on it's conditions.  Once the page is refreshed, everything displays properly.

I feel like I'm missing something simple, but who knows!
Photo of Ben Rose

Ben Rose

  • 222 Points 100 badge 2x thumb

Posted 3 years ago

  • 1
Photo of Matt Sones

Matt Sones, Champion

  • 31,478 Points 20k badge 2x thumb
Could be a model order issue, if you're using 'field from another model' conditions. Is your Duplicate Leads model before your Leads model in your list? Skuid will process models in the order that they're listed in your models list. 

There's probably a much better solution, but as a test you could have you button call the query on both models twice in a row.
Photo of Ben Rose

Ben Rose

  • 222 Points 100 badge 2x thumb
Hey Matt, thanks for the quick response!  I am using the 'field from another model' conditions on the Duplicate Lead model, but it comes after the basic Lead one.  I tried playing around with the order of the queries on Save as well, but it doesn't seem to have helped.
Photo of Matt Sones

Matt Sones, Champion

  • 31,478 Points 20k badge 2x thumb
Ben,

If you haven't already, try to query both models in the same query action.
Photo of Ben Rose

Ben Rose

  • 222 Points 100 badge 2x thumb
Yup, already doing that!  The custom Save button just has 1 Save Model Changes and 1 Query Models action which apply to both the Lead and Duplicate Lead models.
Photo of Matt Sones

Matt Sones, Champion

  • 31,478 Points 20k badge 2x thumb
Ok. When you mentioned the order of the queries, I thought you had separated them into different actions.
Photo of Ben Rose

Ben Rose

  • 222 Points 100 badge 2x thumb
Update: So I figured this out, but not entirely sure why it works!  In the "Field from another model" conditions for my Duplicate Leads model, I switched the operator from = to 'in', and now the whole thing is working perfectly.