0

I am trying to call the Lightning component through a URL in the Page Detail button. The lightning component (CaseChangeStatus) is like below

Component

<aura:component implements="lightning:isUrlAddressable">
  <aura:attribute name="record" type="Case" default="{ 'sobjectType': 'Case' }" />
  <aura:attribute name="recordId" type="String" />
  <aura:attribute name="complete" type="Boolean" default="false" />
  <force:recordData recordId="{!v.recordId}"
                    fields="['CaseNumber','Status']"
                    targetFields="{!v.record}"
                    aura:id="recordData"
                    mode="EDIT"
                    recordUpdated="{!c.recordLoaded}" />
</aura:component>

Controller

({ 
  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") {
            $A.get("e.force:closeQuickAction").fire();                                  
        }          
      }));
  }
  }})

I tried to call the component from the URL button like

/lightning/cmp/c__ChageCaseStatus?c__recordId={!Case.Id}

But I ended up getting the blan screen

enter image description here

0

This is odd, and I had to struggle with this the first time I used the lightning:isUrlAddressable interface. It turns out that the component name and any URL attributes must be prefixed with c__

Your URL should be /lightning/cmp/c__ChageCaseStatus?c__recordId={!Case.Id} or /lightning/cmp/c__ChageCaseStatus

3
  • I tried with c__ it takes to me blank page – user81642 Apr 3 '20 at 15:04
  • I think there is a conflict between force:hasRecordId and lightning:isUrlAddressable. Try removing force:hasRecordId and adding recordId as an attribute – Mitch Spano Apr 3 '20 at 15:06
  • Could you put something in your component ? Like a lighting card or simple message, may be force:recordData might be having issue and your navigation might have already worked. – Kiran Machhewar Apr 3 '20 at 17:24
0

The url attributes must be suffixed c__ as per the documentation of lightning:isUrlAddressable

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.