Skip to main content

I have 2 Record Types for Account: Persona Fisica and Persona Moral.


I have 2 Skuid pages AccountMoralEdit and AccountFisicaEdit, both are used for new and edit. I have the following Page Assignments:

Account / New / Org Default / Persona Fisica / AccountFisicaEdit

Account / New / Org Default / Persona Moral / AccountMoralEdit

Account / Edit / Org Default / Persona Fisica / AccountFisicaEdit

Account / Edit New / Org Default / Persona Moral / AccountMoralEdit



And the following VF Pages:

AccountNew


<apex:page action=“{!redirect}&objecttype=Account&actiontype=New” extensions=“skuid.Redirects” standardcontroller=“Account”></apex:page>



AccountEdit


<apex:page action=“{!redirect}&objecttype=Account&actiontype=Edit” extensions=“skuid.Redirects” standardcontroller=“Account”></apex:page>


And the Account Action Overrides:

Edit → VF Page: AccoundEdit

New → VF Page: AccountNew


The problem I have is the following: when I create a new Account of record type ‘Persona Moral’ the correct Skuid page is loaded but the new record is saved with ‘Persona Fisica’ record type. So my apex validations fail because of this. Any ideas?

The default record type on your Account object is probably “Persona Fisica”. To fix that you’re probably going to have to change it manually/via code.


Skuid Pages do not automatically assign a RecordType to a new record just because you’ve used a Skuid Page as the Page Assignment for an object’s New action, because your “new” page might have multiple Models on it, and we don’t want to assume too much about how your page’s Models are working. Ordinarily Skuid Models just assign the Default Record Type for a User’s Profile / for that Object to new records that you create in the Models.

But it’s very easy to have a Model on your Skuid Page manually specify that you want a particular Record Type to be used when creating a new record in a Model. Any Conditions on your Models will be applied as default values for any new records created in Models, so if you add a Condition on the RecordTypeId field, this will set the Record Type of new records created in that Model.

So in your scenario, you probably have two different Skuid Pages, one for each Record Type, and each of those pages has a Model that is being used to create the new Account. So you just need to have a different Condition on each Model that specifies the RecordType you want to use. Your Conditions should be like this:

Field: RecordTypeId
Operator: =
Content Type: Single specified value
Value: EITHER a RecordType’s 18-digit Id, or (recommended for ISV’s / OEM’s) its API / Developer Name, e.g. “Persona_Fisica”
State: Always On



Thanks to both of you. Zach your solution was indeed super easy to implement and it now works as expected.


Reply