strange things with model query & field editor

Matt SonesMatt Sones ✭✭
edited June 25 in Problems
I'm trying to set up a button to create a new row in a model and a field editor to display the fields. I get it to work the first time the button is clicked, but upon subsequent clicks the field editor is duplicated (there are now two rows in the model, not one). I thought that I could simply add a "query model" action to the button, but when I do so, the model pulls the first row in the object on page load, before the button is even clicked. Nothing appears to happen when I click the button.

Here are the set-ups:
Model
image
I tried playing around with the ORDER BY field, and I could get different results, but nothing that would show the new row that I created with the button.

Button Actions
image
I get the same result whether I choose to place the row at the start or the end of model data.

On page load, I see this, which is what I want:
image

After running the New Lead button, I see this (not what I want):
image
That's apparently the first row in the model.

What I want to see it the same thing that I see on Page Load.

Anyone have an idea on this?


Comments

  • Pat VachonPat Vachon ✭✭
    edited June 25
    Does it need be it's own page?
  • Pat VachonPat Vachon ✭✭
    edited June 25
    This is a somewhat odd approach, but I suggest the following.

    Set the model to query 0 rows, not to create a default row if model has none and to load model data on page load.

    image

    Set an action on the CallLog model for initiating event "Requeried". Use the following Action.
    1. Create new row in model (use default values if necessary)

    The Save button only saves the model.

    The New Lead button also queries the model

  • Matt SonesMatt Sones ✭✭
    edited June 25
    brilliant! works like a charm. Thanks for your help.
  • Pat VachonPat Vachon ✭✭
    edited January 2016
    Great! Wasn't sure it was going to work this new way I thought up just then.
  • Matt SonesMatt Sones ✭✭
    edited June 25
    Pat,

    Definitely slick. One problem I run into, though, is that I'd like to make other parts of the page render conditionally based on the values of the fields that the user sets in the model. However, we've set the model to have 0 rows...

    Any thoughts on how to handle that?
  • Pat VachonPat Vachon ✭✭
    edited January 2016
    skype me for a screenshare.
    pat.vachon.77 
  • Matt SonesMatt Sones ✭✭
    edited December 2016
    i don't skype, but I'll install and set up an account, unless i can invite you to a gotomeeting?
  • Pat VachonPat Vachon ✭✭
    edited January 2016
    Seems the new model has one row but only after all models set to load on page load have been queried.  Conditional rendering on components and their elements that use this new model should work dynamically. All other rendering only works on query.

    The other thing is that models load sequentially bases on the order in the page builder.
    1. Models with URL parameters.
    2. Models with conditions that point to models that use URL parameters as part of the condition.
    3. Models that does any conditional rendering on the first two types of models. 

    Note: Models that don't load on page load can be anywhere you'd like since don't rely on page load order.
  • Pat VachonPat Vachon ✭✭
    edited January 2016
    a gtm works too. [email protected]
  • Matt SonesMatt Sones ✭✭
    edited December 2016
    Pat--

    Thanks for your help on this.

    I was able to get this working on Save of the leads model, but not dynamically.

    Instead of using javascript and those custom components to create the script buttons and text, I set up skuid models for each individual script, used a page title component for the button (now two buttons...one to open the script and one to close it, conditionally rendered) and a field editor for the text. I'm pretty happy with the results.

    Script open:
    image
    Script Closed:
    image

    If I set the model of the page title components to the leads model, I can get the pagetitle and buttons to conditionally render based on a field in that model, but only after saving it.

    In the long run, I decided that the conditional rendering of the scripts isn't a huge requirement. The users should be intelligent enough to click the correct script button for the circumstances,

    Thanks again for your help, Pat!
  • Matt SonesMatt Sones ✭✭
    edited February 2017
    This can be marked closed/solved. Thanks!
  • Pat VachonPat Vachon ✭✭
    edited January 2016
    Your welcome. Satisfied that you got the core functionality you were looking for.
  • Rob HatchRob Hatch 🛠️ 
    edited February 2017
    Glad you got things working.  I am still not happy that you have to save the lead data to get the conditional rendering to work correctly.  I have good examples of conditional rendering working on new record pages.  It all happens client side,  so no save is necessary to get the rendering to work.   If you want to explore further let us know. 
  • Matt SonesMatt Sones ✭✭
    edited December 2016
    I'd love to explore that further!
Sign In or Register to comment.