Same page overriding new and edit?

  • 1
  • Question
  • Updated 5 years ago
  • Answered
This is probably pretty basic but is it possible to use the same page to override both the New and the Edit buttons on a custom object?  It seems you need to configure the model differently for these different scenarios.
Photo of John Davies

John Davies

  • 164 Points 100 badge 2x thumb

Posted 5 years ago

  • 1
Photo of Rob Hatch

Rob Hatch, Official Rep

  • 44,006 Points 20k badge 2x thumb
Yes,  this is possible.  If you don't include a specific action definition in the visualforce page that wraps the skuid page, you can use that one visual force page to override multiple actions  (Under Buttons, Links and Actions) for the custom sObject. 

Your visual force code will look somthing like this: 

<apex:page action="{!redirect}&page=SkuidPage" extensions="skuid.Redirects" standardController="CustomObject__c">

</apex:page>
Where you replace "SkuidPage" with the name of your page,  and "CustomObject__c" with your object name.

Photo of Zach McElrath

Zach McElrath, Employee

  • 49,004 Points 20k badge 2x thumb
John as far as the Models in your Skuid Page are concerned, this is possible, but it might be easier and more clean to create separate Skuid Pages to use for the New and Edit actions.

To have a single Skuid Page be used for both the New and Edit actions, you will have to do the following:

1. In your main Model's Advanced properties, check both "Create Default Row in Model" and "Load Model data on page load", and limit the number of records to 1.
2. Your main Model should have one Condition, of type "URL Parameter", on the Id field, set to pull in the "id" parameter --- with "If this Parameter is not provided, then..." set to "Abort this Model's Query". That way Skuid won't try to query for any records of that object if no id parameter is found (which is what you want if you are using the page for the New action). 
Photo of John Davies

John Davies

  • 164 Points 100 badge 2x thumb
Thanks @Zach and @Rob that is a great help.  All good.
(Edited)