4

I have a usecase where I want to update some field values at the record before firing the component.find("edit").get("e.recordSave").fire() event.

Here is the markup which I am using

<force:recordEdit aura:id="edit" recordId="0069000000PUrus"/>
<lightning:button label="Save &amp; Next" onclick="{!c.doSaveAction}" />

Controller

doSaveAction : function(component, event, helper) {
    // Here, can I update a field value before sending record to save event
    component.find("edit").get("e.recordSave").fire();
}

Please let me know if it is possible.

This question had a bounty worth +50 reputation from Naval Sharma that ended 13 mins ago. Grace period ends in 23 hours

This question has not received enough attention.

I need a working solution for the above problem.

5

I haven't done this with force:recordEdit but I have done it with Lightning:recordEdit so if thats an option you could just switch to that and the code below will allow you to update object fields before they are passed to the server. Otherwise you might be able to apply similar logic to force:recordEdit

AURA

<lightning:recordForm aura:id="createCaseForm"
        recordTypeId= "{!v.recordTypeId}" 
        onsubmit="{!c.handleCaseSubmit}"
        objectApiName="Case"
        fields="{!v.caseFields}"
        mode="edit"
        columns="2"
        variant="brand"
        >
    </lightning:recordForm>

JS

doSaveAction : function(cmp, event, helper) {
    event.preventDefault(); // stop form submission
    var eventFields = event.getParam("fields"); // gets all the fields for the object
    eventFields["AccountId"] = cmp.get("v.accountId");
    eventFields["ContactId"] = cmp.get("v.contactId");
    eventFields["Status"] = "In Process";
    cmp.find('createCaseForm').submit(eventFields);
},
  • Will it create the layout automatically as per the record type? – Naval Sharma Jan 16 at 15:34
  • Yes, it will grab the page layout based on record type. I also discovered a way to hide specific fields like recordId, let me know if you run into that issue and I'll send it your way – Calvin OKeefe Jan 16 at 15:44
  • any luck getting it to work? – Calvin OKeefe Jan 17 at 16:35

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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