• Maggie Emma
  • NEWBIE
  • 0 Points
  • Member since 2017

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 3
    Questions
  • 0
    Replies
In Lightning I want to be able to clone my Opportuntiy along with the related products and product schedules, and when I clone the record I want to be able to edit fields for the new record (just like it does with the standard Clone button). I have used process builder and flow to clone the Products, and I have created a custom button to use the flow. When I click the custom button, I get a message saying "Your Flow Finish"
User-added image


I want the newly cloned record to pop up instead. Any ideas on how this can be acheived?

Much appreciated!
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!!
Hello. I have the following javascript button I need to convert to a lightning component. I'm running into issues with the Apex class. How do I get the 4 account field values and do the 'if statements'? Once I have those field values, how do I create the Lightning Component controller.js? I've read plenty of articles on this but still can't figure it out, can someone please help me with the acutal code?

Original JavaScript button code - 

var taxID= '{!Account.tax__c}'; 
var accID = '{!Account.Id}'; 
var type = '{!Account.TypeId}'; 
var typeName = '{!Account.TypeName}'; 
if(taxD!=null) 

if(typeName !='Personal'){ 
alert('Post message here.'); 

if(type != '987652930764JKS'){ 
var url= '/apex/VisualForcePage?id=' + accID; 
showSplashView(); 
window.location = url; 

else 

var url= '/apex/VisualForcePage?id=' + accID+'&Personal=true'; 
showSplashView(); 
window.location = url; 


else 

alert('Tax Id required'); 
}

Lightning Component (so far) - 

<aura:component controller="Component_Controller" implements="force:lightningQuickActionWithoutHeader,force:hasRecordId,force:hasSObjectName" access="global">
    <aura:attribute name="tax" type="String"/>
    <aura:attribute name="type" type="String"/>
    <aura:attribute name="typeName" type="String"/>

    <aura:handler name="init" value="{!this}" action="{!c.doInit}"/>
    
    <div class="slds-p-around--x-small slds-align_absolute-center">
           <h2>Post message here.</h2>
    </div>
    <div style="text-align:center">
    <lightning:button label="OK" onclick="{!c.launch}" class="slds-m-bottom-medium"/>
    </div>
</aura:component>

Lightning controller.js (so far) - 

({ 
    doInit : function(cmp) {

        })
    },
    
    launch : function(component, event, helper){
        //on click of "OK", redirect to visualforce page
        
        var urlEvent = $A.get("e.force:navigateToUrl");
        urlEvent.setParams({"url":"/apex/VisualForcePage?id=" + cmp.get("v.recordId") });
        urlEvent.fire();
    } 
})