5

I'm using $A.get("e.force:createRecord") to display record create page for an object, but this doesn't display record type selection screen, we have to pass it explicitly. Default salesforce lightning behavior when user clicks on new record button is it shows record type selection. How I can implement same behavior. I don't want to build custom component for this.

  • do you see record type screen when you are out of lightning and try to create new record from Salesforce classic? – Himanshu Feb 6 '17 at 9:04
  • $A.get is useful in lightning only, in classic I am using URLFOR($Action.ObjectName.New). In classic it shows record type selection screen. – Soham Feb 6 '17 at 9:58
  • Any Luck? Did any one find a way to achieve this functionality? – Din_y Feb 23 '17 at 16:08
2

Currently, it's not possible select a record type in the createRecord component. You can create a dropdown or something with the record types options and then call the createRecord component passing the record type.

Example

var createRecordEvent = $A.get("e.force:createRecord");
    createRecordEvent.setParams({
        "entityApiName": "Contact",
        "recordTypeId": ""
    });
    createRecordEvent.fire();

This a dropdown example for select the record type

<div class="source-center-slds" >
        <div class="slds-p-around--x-large">
            <ui:inputSelect class="slds-select_container myselector"  label="{!'Select ' + v.label +  ' Record Type: '}" aura:id="levels">
                <aura:iteration items="{!v.types}" var="item">
                    <ui:inputSelectOption class="slds-select" text="{!item.Id}" label="{!item.Name}"/>      
                </aura:iteration>
            </ui:inputSelect>
            <button class="slds-button slds-button--neutral slds-not-selected slds-m-top--medium" onclick="{!c.create}">New</button>
        </div>
    </div>

v.types is an array with the record types values

1

3 things to be done to achieve this functionality.

  1. Get the all available Record Types for that object.
  2. Make them available as a list for selection on component.
  3. Pass the selected recordTypeId as second parameter to force:createRecord.

    Check here for more.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.