New Record Page Best Practice?

  • 1
  • Question
  • Updated 4 years ago
  • Answered
  • (Edited)
So I've seen a couple ways to create new records. From what I can tell, there are essentially two types: with and without references set for the parent record through lookup or master-detail.

Without references is the easiest in the sense that all that is needed is one model with the right settings on the model and page.
1. Default Mode for components is Edit
2. Save button has a redirect to /{{Id}}
3. Loan Model data on page load in unchecked
4. Create default row if Model has none is checked

With references we requires the Id's for the records that will be referenced. All the settings from above plus the following:
5.a) The Id of the referenced records to be set as conditions when using step 4 from above or
5.b) The id of the referenced records to be set using merge variables for default values on action Create New Row in Model.

Am I missing anything?
Also, why do the models need to be on the page in order to set the Id of referenced records?
Photo of mB Pat Vachon

mB Pat Vachon, Champion

  • 42,714 Points 20k badge 2x thumb

Posted 4 years ago

  • 1
Photo of Rob Hatch

Rob Hatch, Official Rep

  • 44,006 Points 20k badge 2x thumb
You are not missing anything. 

Let me dig into your question. 

Because you have set your model to not "Load Model data"  the only information that the model knows is what gets set in the model condition.  I.E. the data that gets explicitly passed through a URL parameter.  The URL parameter is usually a parent record ID,  in which case the new model will know the parent record ID,  but not any additional information about that parent record (Including Name).   This may be fine if you want the parent reference stored with the new model but don't need to display it on your new record screen, but if you want the parent name field  (or other data about the parent) displayed on your new record page you'll have to do somthing else. 

The options here are. 
1. Either add additional URL parameters for each piece of data you want displayed on your new record page.  (And make sure to URL encode them for things like spaces and special characters) or. 
2. Have your URL parameter call a second model that loads the necessary data about the parent, and then pass that data into the New Record model using "field from another model" conditions. 

Final Note: 
If you are building a completely separate new record page.  It is not necessary to use your method 5b - as having your model "create new row" will take care of the actions for you.  The "create new actions" are generally used when new records need to be made as part of a broader page. 

Hopefully this is helpful. 
Photo of mB Pat Vachon

mB Pat Vachon, Champion

  • 42,714 Points 20k badge 2x thumb
Hi Rob,

This was helpful.

Basically, the conditions can be used to set any parent (master-detail and lookup) relationships, but this won't enable the ability to see data from these relationships without the corresponding model (SOQL) to pull in the date to be displayed on the page. This is the case even if we choose fields through the relationship in the model. For example, a page to add a contact to an Account with one model for the Contact.



This is only true since the record is new. If it weren't new, then the model (SOQL) would be able to produce Account.Name.

Thanks Rob,

Pat