function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
erikvmerikvm 

Customize the "$A.get("event.force:createRecord")" modal?

I've got a lightning component that lets the user submit a record. Once they hit submit, the standard page for creating the record pops up, which looks like this:


User-added image

 

Is it possible to customize this modal to only display certain things? I'd like it to look like a confirmation page (as they have entered the information for each field in a previous component), something along the lines of

 

"You entered:

Date xx

Dealer: YY

Press save to confirm"

Here's the code for that modal popup:

loadSalesAppointment: function(component, event, helper, customerAccountId) {
        var event = $A.get("event.force:createRecord");     
        if (event) {
            event.setParams({
                entityApiName: "Sales_Appointment__c",
                defaultFieldValues: {
                    Resource__c: component.get("v.resourceId"),
                    Dealership__c: component.get("v.accountId"),
                    Lead__c: component.get("v.customerAccountId"),
                    Start__c : StartDateAndTime,
                    End__c : EndDateAndTime
                }
            })
            event.fire();
        }
        else {
            alert("Not available")
        }
    },
erikvmerikvm
Just to clarify: I still want the modal popup, but just a different look to it
Ashwin Kumar SrinivasanAshwin Kumar Srinivasan
Hi
You can try using overlay library and display body whatever details you have mentioned and then may be use Lightning Data Service to submit the record? - you might need to create object with the default values to be used by data service, please check the links below
https://developer.salesforce.com/docs/atlas.en-us.lightning.meta/lightning/ref_lightning_overlayLibrary.htm
https://developer.salesforce.com/docs/atlas.en-us.lightning.meta/lightning/data_service.htm?search_text=Lightning%20Data%20Service


Thanks
Ashwin Kumar SrinivasanAshwin Kumar Srinivasan
If you want the fields editable, you can try using lightning:recordEditForm in an Overlay Library (https://developer.salesforce.com/docs/atlas.en-us.lightning.meta/lightning/ref_lightning_overlayLibrary.htm) and set the default values but this does not work with Master Detail fields if they are not reparentable
<aura:component implements="force:appHostable" >
    <lightning:recordEditForm objectApiName="Contact">
        <lightning:messages />
        <lightning:inputField fieldName="FirstName" />
        <lightning:inputField fieldName="LastName" />
        <lightning:inputField fieldName="Email" />
        <lightning:inputField fieldName="AccountId" value="0011p00001ZQDGzAAP"/>
        <lightning:button class="slds-m-top_small" variant="brand" type="submit" name="update" label="Update" />
    </lightning:recordEditForm>
</aura:component>