Using a popup to create new records - need to reset model to empty on each popup

I am using a popup with a model set to “Create Default Row if Model Has None” (and disable “Load Model Data on Page Load”). This allows me to create a new row on an object in the popup. In this case, it is creating a Case Comment off a Case model. However, if I click that popup again, I see the same data from the last time I clicked it, even though I’ve used a snippet to save the data (updateData) and refreshed the main page. I’d like the next popup to be empty, waiting for a fresh new comment rather than seeing/editing the prior comment. If I call model.createRow, I do get a fresh new row … but I also see the prior row in the popup (and I’ve set the model “Max # of Records (Limit)” to 1, though I know that’s only used to load new data). Is there any way I can take my model and “reset” it back to the original, new state from within a snippet? Or remove the row from the model without deleting the row from the object? Thanks, - Chris

This is a great question.  At this point we have lots of thie pieces needed to make this happen but there are some gaps.  We are in active development to close these gaps,  and have shown the way forward in our mobile composer which has the concept of “multiple actions” that can be connected to a user interaction (like clicking save).  

Until we get this put in place there are a few options. 

1.  Since you’ve already gone the javascript route to effect some interactions,  you might go ahead and use the API to add new rows to your “new record” model so that blank rows are presented to the user the next time they open the popup. That code would look somthing like this: 

            // Create new Rows in our NewOpp model for the NEXT time someone creates a new opp.                               skuid.model.updateData(NewOpp,function(){                 NewOpp.createRow();                NewLineItems.createRow(); }); 

2. If you put a page include in your New record popup.  This included page (and its models) will refresh every time the popup is opened.  This will keep you from seeing the data you had previously entered the last time you entered the popup. 

Thanks … I’m trying the Page Include idea, but I’m getting an error when I click the button that loads the popup window. The popup appears and a “Loading…” message is there, but nothing happens. On the browser console, I see a 404 error for the page: “GET 404 (Not Found)” I see that the VF page Include exists in your package. If I try to access the URL above directly, I get a 404. But if I access the page as “skuid__include” a page loads (of course, not a very usable one) - so I’m wondering if there is maybe a bug with the URL path here? Thanks, - Chris

Just making sure here. 
1. Have you actually created a second skuid page that has the new record form? 
2. Are you sure you connected that skuid page to the page include component? 

We did have a VF page include option,  but found that it caused many more problems than it solved.  WE have removed that option from our page include component. 

If this doesn’t help,  maybe you can give us login rights to your org and we can check it out. 

Yes to both questions. I went ahead and made a very simple example - a base page with no models, just a page title/popup button/page include … and a popup page with just a template w/text. I continued to get the error … but all my page testing happens with a restricted user (Customer Community Login User profile) so I tried it on my main user, and it works. So looks like I have a permissions issue. To try to isolate the missing permission, I added all VF pages, and all APEX classes to my community user profile, as well as gave them Skuid Builder permission set (they already had viewer) - but I’m still not getting the page to appear. And since there are no models in use I didn’t adjust any object permissions (my other pages work fine for that profile, that include viewing, creating and editing Case, CaseComment, Attachment and more). I have limited ability to edit System permissions due to the restricted rights of a Community user (for example, I am not allowed to tuen on the API Enabled system permission), so I didn’t change anything there. I also tried a quick Debug Log tracking on my community user, and (using default log capture settings) I didn’t see any indications of an error. Any thoughts on what permission I might need for my Customer Community user? Thanks, - Chris

Any thoughts on the permissions issue I’m having (see prior comment)? It does appear that the popup will refresh the model if I can just get the page to work on the Salesforce Communities page… Thanks! - Chris

Hi Chris, When you use Communities / Sites with Skuid, there’s an extra step you have to take: you have to make local copies of the Skuid “Include”, “ExportData”, and “UploadImage” Visualforce Pages, and then grant Profile Security to those pages for all users. So go to Setup > Pages, and find the pages installed with Skuid called “Include”, “ExportData”, and “UploadImage”. Create new Visualforce Pages in your org with the same exact names as these VF Pages, and the same exact contents. Once these pages are created, click “Security” next to them in the Visualforce Pages list and ensure that your Profiles all have access to these 3 VF Pages. Let us know if that doesn’t fix the popup problem in the Community. Zach

That did it! The permissions issue fixed the community access, and the dynamic load fixed the model reset. Thanks