+ Start a Discussion
D VelD Vel 

Change case status using the lightning component through the quick action

I am trying to call the lightning Components from the Quick Action to change the status of Case to Closed on click of a button.
<aura:component implements="force:hasRecordId,force:lightningQuickActionWithoutHeader">
  <aura:attribute name="record" type="Case" default="{ 'sobjectType': 'Case' }" />
  <aura:attribute name="complete" type="Boolean" default="false" />
  <force:recordData recordId="{!v.recordId}"
                    recordUpdated="{!c.recordLoaded}" />
  recordLoaded: function(component, event, helper) {
    var caseRecord = component.get("v.record"),
      recordData = component.find("recordData");

      caseRecord.Status = 'Closed';

      if(!component.get("v.complete")) { // Avoid infinite loop
      component.set("v.complete", true);
      component.set("v.record", caseRecord);
      recordData.saveRecord($A.getCallback(function(result) {
        if(result.state === "SUCCESS" || result.state === "DRAFT") {
        } else { /* show an error here */ }
But when I click on the Quick Action it throws error like
User-added imageNot sure what I am missing here, any help is greatly appreciated

ShirishaShirisha (Salesforce Developers) 


Can you please try the below code to set the mode to EDIT:

<force:recordData recordId="{!v.recordId}" fields="['CaseNumber','Status']" targetFields="{!v.record}" aura:id="recordData" mode="EDIT" recordUpdated="{!c.recordLoaded}" />

Kindly let me know if it helps you and close your query by marking it as solved so that it can help others in the future.

Warm Regards,
Shirisha Pathuri