Create New record button error after using multiple times

  • 1
  • Question
  • Updated 4 years ago
  • Answered
Archived and Closed

This conversation is no longer open for comments or replies and is no longer visible to community members. The community moderator provided the following reason for archiving: Issues that have been fixed. Duplicate records.

I have created a Create New Location button which shows a Popup where you enter in the info and it creates a new record in that object. Works perfectly. My issue is if I want to add another location after I have saved one just prior it doesn't show up a blank popup as it does the first time. 

The 2 questions I have are:
1. How do I get skuid to refresh the popup on its own so if we need to use this button more then once without refreshing the page it comes up blank and ready to receive info each time.

2. I would like to create a "Save and New" button where I can enter in new record one after the other. 



Here are screen shots showing the process:

This is what shows up when I click new location
 


Then I enter in info and click save.... (at this point everything is working well)



Popup closes and I then click "New Location" button again to add another record and this is what shows up:



How do I get this to be the original blank layout shown in screen shot 1?
Photo of Megan Vaughan

Megan Vaughan

  • 872 Points 500 badge 2x thumb

Posted 4 years ago

  • 1
Photo of Josh Cutler

Josh Cutler, Official Rep

  • 864 Points 500 badge 2x thumb
1. We can potentially tweak the answer to question 2 to handle this question, but I think it is worth your time to have a direct answer to this question.

It looks like your Model for new records needs a Condition that keeps the Model empty.

You probably set up the Model for your popup's Field Editor with similar settings as the Model in Step 4 of the Create New Record tutorial. If that's the case, then you're ready to add the Model Condition.



Click Add Condition and configure the Condition to set the Id field on your Model (in this example, it's the Accounts object) to a blank value. This will prevent your Field Editor from loading records after you've created a new record.

2. We can create the desired behavior without using code!

Add a Page Title component to your popup above the Field Editor. Click the Add Button button in the Page Title component.




Change the Button Label and Button Icon according to your requirements. Choose Run Multiple Actions as the Action Type from the picklist.



Click on the Actions heading in Button Properties.

Add the following actions by clicking on the Add Action button and selecting the appropriate action from the Action Type picklist: Save Model(s), Query Model, and Create new row in Model.

Make sure Save Model(s) has the Models to Save set to the correct Model.

Choose the correct Model in the Query Model and Create new row in Model action settings.

EXPLANATION: these settings will tell the Save and New button to 1) save the data in the form as a new record, 2) re-query the Model which uses the condition we created earlier to empty the Model, and 3) creates a new record in the Model which gives us the blank form.

NOTE: if you need the Skuid page behind the popup to 'refresh', you can change the Query Model to Query Models. This gives you the ability to requery the Models on other components on your page. For example, if you create a new record and you want it to show up in the Table on your page without reloading the whole page, then you use Query Models to also refresh the Model attached to that Table. Pretty slick.

Save your work and test it out!

Let us know if you have any other questions.

-Josh
Photo of Megan Vaughan

Megan Vaughan

  • 872 Points 500 badge 2x thumb
So I followed the directions above and have created my "Save & New" button and 2 errors occur:

1. the popup closes when I click my "Save & New" button -- it directs me back to my original screen. 
(more like a save and close)

2. when I go to create a new location fro my main screen again after it closes I get a blank field. (see screen shot)
Photo of Megan Vaughan

Megan Vaughan

  • 872 Points 500 badge 2x thumb
Screen shots to show my actions
Photo of mB Pat Vachon

mB Pat Vachon, Champion

  • 42,966 Points 20k badge 2x thumb
In the button that invokes the popup, add a Query Action for the model being used in the popup as the first action. This will clear what's in the model.
(Edited)
Photo of mB Pat Vachon

mB Pat Vachon, Champion

  • 42,966 Points 20k badge 2x thumb
Also, make the Advanced settings are like this.

(Edited)
Photo of Megan Vaughan

Megan Vaughan

  • 872 Points 500 badge 2x thumb
I made the changes you suggested but my "New Location" button won't work at all now. It shows nothing (screen shot 1)

1



My initial button "New Location" the action type was popup but I changed it to "run multiple actions" I added a query action  (new location model) and then show popup. 


I thought the blank field editor shown in the first screen shot was due to the fact that I have a condition in the model "New Location" id= none/blank (as directed above) but I have tried it with and without that condition and am stuck at the same place still. 
Photo of mB Pat Vachon

mB Pat Vachon, Champion

  • 42,966 Points 20k badge 2x thumb
Yeah ... changing to run multiple actions does not transfer anything over. The popup action you added would be blank. Only way to transfer would be via working with the XML. Otherwise have to rebuild the popup.
Photo of Megan Vaughan

Megan Vaughan

  • 872 Points 500 badge 2x thumb
I did rebuild the popup... that isn't the issue....
Photo of mB Pat Vachon

mB Pat Vachon, Champion

  • 42,966 Points 20k badge 2x thumb
Photo of Megan Vaughan

Megan Vaughan

  • 872 Points 500 badge 2x thumb
;( nope still doesn't work. It now will only flash the popup and then close the popup before you even have time to enter in anything. Plus the Field editor is not showing up in the popup.
Photo of mB Pat Vachon

mB Pat Vachon, Champion

  • 42,966 Points 20k badge 2x thumb
At this point I have to bow out and pass the baton on to Skuid folks. They can login and poke around your page.

It should work though. I use this methodology myself all the time.
Photo of Megan Vaughan

Megan Vaughan

  • 872 Points 500 badge 2x thumb
Thanks so much for your help!!

Skuid.....???
Photo of Rob Hatch

Rob Hatch, Official Rep

  • 44,228 Points 20k badge 2x thumb
Oh the Skuid was out eating Mexican food from John's favorite place "Macho Taco"   Now we all need a Macho Nap...  Sorry.. 

I'm not exactly clear what you have tried and what you have not tried.  But here is the cannonical method for doing what you are attemping. 

Create a "New Model"  that does not load data or create a new row (advanced properties of the model) 

Create Action sequence like this:
  • Cancel Models: [New Model]
  • Create new row in Model [New Model]
  • Show Popup
In Popup, Create  buttons that each Run Multiple Actions:

Save Button.  Actions: 
  • Block UI with message: Saving...
  • Save Models
  • Save Models <MAIN TABLE MODEL>
     -  On Error Action: Unblock UI
    -   Close All Popups
  • Query Models <MAIN TABLE MODEL, NEW MODELS>
  • Unblock UI
  • Close All Popups
Cancel Button. Actions: 
  • Cancel models
  • Close All Popups
Save and New Button.  Actions: 
  • Block UI with message: Saving...
  • Save Models
  • Save Models <MAIN TABLE MODEL>
     -  On Error Action: Unblock UI
    -   Close All Popups
  • Query Models <MAIN TABLE MODEL, NEW MODELS>
  • Close All Popups
  • Create new row in Model [New Model]
  • Show Popup
  • Unblock UI

You should not need to worry about context conditions,  or model conditions, or any other foolishness. 

If this is still not working for you - grant us login rights and we'll take a look. 
Photo of Megan Vaughan

Megan Vaughan

  • 872 Points 500 badge 2x thumb
I granted Skuid login under our developer org. The page is Job_Detail_Master the tab is Locations and the models are Locations and New Locations.

Thanks!
Photo of mB Pat Vachon

mB Pat Vachon, Champion

  • 42,966 Points 20k badge 2x thumb
I have a tweak to suggest for creating new records.



Setting Max # to 0 means that it will never load a previously created record.

Setting Create Default means it will create a new row each time it's queried.

The action sequence would then be.

Create Action sequence like this:
  • Cancel Models: [New Model]
  • Create new row in Model [New Model]
  • Query Model [New Model]
  • Show Popup
In Popup, Create  buttons that each Run Multiple Actions:

Save Button.  Actions: 
  • Block UI with message: Saving...
  • Save Models [New Model]
  • Save Models <MAIN TABLE MODEL>
     -  On Error Actions: 1. Show Message "Error Saving New ...." for 3 seconds.    2. Unblock UI    3. Close All Popups
  • Query Models <MAIN TABLE MODEL, NEW MODELS>
  • Unblock UI
  • Close All Popups
Cancel Button. Actions: 
  • Cancel models (clicking on the X would circumvent model cancel)
  • Close All Popups
Save and New Button.  Actions: 
  • Block UI with message: Saving...
  • Save Models [New Model]
  • Save Models <MAIN TABLE MODEL>
     -  On Error Actions: 1. Show Message "Error Saving New ...." for 3 seconds.    2. Unblock UI    3. Close All Popups
  • Query Models <MAIN TABLE MODEL, NEW MODELS>
  • Close All Popups
  • Create new row in Model [New Model]
  • Show Popup
  • Unblock UI
Photo of mB Pat Vachon

mB Pat Vachon, Champion

  • 42,966 Points 20k badge 2x thumb
This last post is almost working exactly as I thought it would. Can't Query to create a default new row if max # of record is set to 0. It would simplify things if we could do this though. The added benefit to this is that default values can be set as conditions. This could be handy if you happen to make new rows from more than one button.

Going to submit an idea
Max 0 and Create New Row create new row on query or page load.
Photo of Megan Vaughan

Megan Vaughan

  • 872 Points 500 badge 2x thumb
well unfortunately neither seem to be working. I have granted skuid log in rights in our dev. org. Thanks again for the help-- I have no idea what I am doing wrong!!! 
Photo of Megan Vaughan

Megan Vaughan

  • 872 Points 500 badge 2x thumb
Skuid can you give me any more suggestions?
Photo of Rob Hatch

Rob Hatch, Official Rep

  • 44,228 Points 20k badge 2x thumb
Meghan.  I took a look at your Job Detail Master page and found the "New Location" button.  It doesn't have any of the action framework recipie that I laid out above.  The tweaks that Pat reccomended are viable, but there are good reasons for the suggestion we made. Can you try to implement that recipie?  Or did you implement it in another page? 

Thanks 
Photo of Megan Vaughan

Megan Vaughan

  • 872 Points 500 badge 2x thumb
I did implement your directions. I had to change it back just so I could enter in locations - Even though I had to manually refresh the page each time. I've created a cloned page and implemented your suggestions again in a page called "Job Detail Master Skuid HELP". To preview use JOB-000019
Photo of Megan Vaughan

Megan Vaughan

  • 872 Points 500 badge 2x thumb
I did implement your directions. I had to change it back just so I could enter in locations - Even though I had to manually refresh the page each time. I've created a cloned page and implemented your suggestions again in a page called "Job Detail Master Skuid HELP". To preview use JOB-000019
Photo of Emily Davis

Emily Davis, Employee

  • 3,514 Points 3k badge 2x thumb
Megan,
Rob's out for a few days. I'm going to respond to you in an email. Hopefully we can get this figured out!
Emily
Photo of mB Pat Vachon

mB Pat Vachon, Champion

  • 42,966 Points 20k badge 2x thumb
This one is solved. :D

This conversation is no longer open for comments or replies.