Skip to main content

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


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


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:


After running the New Lead button, I see this (not what I want):


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?

Does it need be it’s own page?


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.

c0c99f08b5a65d2125a6262584d878b311aab856.png

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


brilliant! works like a charm. Thanks for your help.


Great! Wasn’t sure it was going to work this new way I thought up just then.


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?


skype me for a screenshare.
pat.vachon.77 


i don’t skype, but I’ll install and set up an account, unless i can invite you to a gotomeeting?


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.


a gtm works too. pat.vachon.77@gmail.com


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:


Script Closed:


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!


This can be marked closed/solved. Thanks!


Your welcome. Satisfied that you got the core functionality you were looking for.


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. 


I’d love to explore that further!


Reply