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
Maggie EmmaMaggie Emma 

Help with Lightning Component Quick Action

Hello Everyone!

I have the following lightning component and controller.js. This code was previously done in a javascript button, and I am trying to make it lightning compatable by using quick actions and lightning components.When the user clicks on the button, I want them to be displayed with a message "After completion of assessment, please review". From here the user will 'OK' and be redirected to a visualforce page. The visualforce page the user is directed to is dependent on the Record Type. I'm looking for guidance on how to fix this code.

The error I am getting is this -'Action failed: forceChatter:lightningComponent$controller$doInit [Right-hand side of 'instanceof' is not an object]

Component -
<aura:component implements="force:lightningQuickActionWithoutHeader,force.hasRecordId" 
                access="global">
    <aura:attribute name="account" type="Object"/>
    <aura:attribute name="record" type="Object"/>
    
    <force:recordData aura:id="accountData"
                      recordId="{!v.recordId}"
                      targetFields="{!v.record}"
                      fields="NRF__c, Name, RecordType.Name"
                      mode="view"/>
   
    <aura:handler name="init" value="{!this}" action="{!c.doInit}"/>
     
    <div style="text-align:center">
    <lightning:button label="OK" onclick="{!c.launch}" class="slds-m-bottom-medium"/>
    </div>
</aura:component>

Controller.js - 
({ 
    doInit : function(cmp, event, helper) {
        var accId = cmp.get("v.recordId");
        var NRF = cmp.get("v.record.NRF__c");
        var recordType= cmp.get("v.record.RecordType.Name");
        
        if(NRF !=null) 
        { 
            if(recordType !='Retail'){ 
                alert('After completion of the assessment, please review.'); 
            } 
            
            if(recordType = 'Retail'){
                var urlEvent = $A.get("e.force:navigateToURL");
                urlEvent.setParams({
                    "url" :"apex/na_maintenance?id=" + accId+"&Retail=true",
                    "isredirect" : "true" });
                urlEvent.fire();
                }
            }
        else {
            alert('Please enter a valid #');
        }
    },

    launch : function(component, event, helper){
         var urlEvent = $A.get("e.force:navigateToURL");
                urlEvent.setParams({
                    "url" : "/apex/na_maintenance?id=" + accId,
                    "isredirect" : "true" });
                urlEvent.fire();
                } 
});
Thanks in advance!!
Naveen KNNaveen KN
Did you debug the code? Use console.log or alerts and see in which step you are seeing that error. 

Naveen
Naveen KNNaveen KN
and also change this force.hasRecordId to force:hasRecordId

Naveen
Team codengine.in