• Hruday
  • NEWBIE
  • 10 Points
  • Member since 2020

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 4
    Replies
I am trying to build a quick action, when clicked, will check for the Status field. IF status != Closed, wil redirect to visualforce page. Below is my component and controller codes. 
CloseCase.cmp
<aura:component implements="force:lightningQuickActionWithoutHeader,force:hasRecordId,flexipage:availableForAllPageTypes">
     <!-- This attribute saves the record ID -->
    <aura:attribute name="recordId" type="String" />
     <aura:attribute name="CaseObject" type="Object" /> 
    <aura:attribute type="Object" name="record"/>
 
    <aura:attribute name="CaseStatusValue" type = "String" /> -->
   

   <aura:attribute name="recordLoadError" type="String"/>

   <force:recordData aura:id="recordLoader"
   recordId="{!v.recordId}"
   fields="Name,Status"
   targetFields="{!v.CaseObject}"
   targetError="{!v.recordLoadError}"
   targetRecord="{!v.record}"                    
   />

    
    
    <!-- This executes a function from the controller as soon as the component is open. 
    This is recommended when the action only processes data and there’s no need for user interaction -->
    <aura:handler name="init" value="{!this}" action="{!c.doInit}" />
</aura:component>

CloseCaseController.js
({
    doInit : function(component, event, helper) {
        var Caseid = component.get("v.recordId");
        var CaseStatus = component.get("v.CaseObject").Status;
        console.log(CaseStatus);
        if(CaseStatus != "Closed"){     
        var urlEvent = $A.get("e.force:navigateToURL");
    urlEvent.setParams({
        "url": "/apex/KBReviewClose?id="+Caseid+"",
        "width" : "700",
        "height" : "1000",
        "scrollbars" : "yes"
    });
        
    urlEvent.fire();
    }
        else{ 
                    var resultsToast = $A.get("e.force:showToast");
                    resultsToast.setParams({
                        "title" : "Failed",
                        "message" : "Case is already closed",
                        "type" : "warning",
                         "duration" : "60000ms"
                    });
                      resultsToast.fire();}
    }
})

On the controller side, I am trying to get the 'Status' value of the case record and redirecting to a visualforce page if status is not equal to 'Closed'.

I am getting the below error. please help.
Error while creating component for lightning component quick action [Action failed: c:LCC_Close_KB_Review_Case$controller$doInit [Cannot read property 'Status' of null]].
 
  • January 20, 2020
  • Like
  • 0
I am trying to build a quick action, when clicked, will check for the Status field. IF status != Closed, wil redirect to visualforce page. Below is my component and controller codes. 
CloseCase.cmp
<aura:component implements="force:lightningQuickActionWithoutHeader,force:hasRecordId,flexipage:availableForAllPageTypes">
     <!-- This attribute saves the record ID -->
    <aura:attribute name="recordId" type="String" />
     <aura:attribute name="CaseObject" type="Object" /> 
    <aura:attribute type="Object" name="record"/>
 
    <aura:attribute name="CaseStatusValue" type = "String" /> -->
   

   <aura:attribute name="recordLoadError" type="String"/>

   <force:recordData aura:id="recordLoader"
   recordId="{!v.recordId}"
   fields="Name,Status"
   targetFields="{!v.CaseObject}"
   targetError="{!v.recordLoadError}"
   targetRecord="{!v.record}"                    
   />

    
    
    <!-- This executes a function from the controller as soon as the component is open. 
    This is recommended when the action only processes data and there’s no need for user interaction -->
    <aura:handler name="init" value="{!this}" action="{!c.doInit}" />
</aura:component>

CloseCaseController.js
({
    doInit : function(component, event, helper) {
        var Caseid = component.get("v.recordId");
        var CaseStatus = component.get("v.CaseObject").Status;
        console.log(CaseStatus);
        if(CaseStatus != "Closed"){     
        var urlEvent = $A.get("e.force:navigateToURL");
    urlEvent.setParams({
        "url": "/apex/KBReviewClose?id="+Caseid+"",
        "width" : "700",
        "height" : "1000",
        "scrollbars" : "yes"
    });
        
    urlEvent.fire();
    }
        else{ 
                    var resultsToast = $A.get("e.force:showToast");
                    resultsToast.setParams({
                        "title" : "Failed",
                        "message" : "Case is already closed",
                        "type" : "warning",
                         "duration" : "60000ms"
                    });
                      resultsToast.fire();}
    }
})

On the controller side, I am trying to get the 'Status' value of the case record and redirecting to a visualforce page if status is not equal to 'Closed'.

I am getting the below error. please help.
Error while creating component for lightning component quick action [Action failed: c:LCC_Close_KB_Review_Case$controller$doInit [Cannot read property 'Status' of null]].
 
  • January 20, 2020
  • Like
  • 0