You need to sign in to do that
Don't have an account?

Lightning Component Cloning Quick Action not working
Needless to say, this is my first venture into Components.....
I'm attempting to use this to create a clone of an Opp. It's set map over two fields. But I can't get it to work. It will only produce a blank square dialog box when the action is used.
Here are the different pieces.
Component :
<aura:component controller="CloneOpp" implements="force:lightningQuickActionWithoutHeader,lightning:actionOverride"> <ltng:require styles="/resource/SLDS202/assets/styles/salesforce-lightning-design-system.css"/> <meta name="viewport" content="width=device-width, initial-scale=1.0"/> <aura:handler name="init" value="{!this}" action="{!c.doInit}" /> <aura:attribute name="recordId" type="Id" /> <aura:attribute name="oppName" type="String" /> <aura:attribute name="typePick" type="String" /> <aura:attribute name="campaign" type="String" /> <aura:dependency resource="c:createRecord"/> <!-- Load the navigation events in the force namespace. --> <aura:dependency resource="markup://force:*" type="EVENT"/> </aura:component>
Controller :
({ doInit: function(component, event, helper) { //call the helper function with pass [component, Controller field and Dependent Field] Api name // alert('Hi'); helper.queryOpp(component, event, helper); }, })
Helper :
({ queryOpp: function(component, event, helper) { var recordId = component.get("v.recordId"); if(recordId!=undefined){ alert(recordId); var action = component.get("c.getDetailsFromOpp"); action.setParams({ recordId: recordId }); action.setCallback(this, function(response){ var state = response.getState(); if (state === "SUCCESS") { var opp = response.getReturnValue(); component.set("v.oppName", opp.Name); component.set("v.typePick", opp.pcikListTest__c); component.set("v.campaign", opp.CampaignId); helper.createOppRecord(component, event, helper); } }); $A.enqueueAction(action); } }, createOppRecord : function (component, event, helper) { var name= component.get("v.Name"); var picklist = component.get("v.typePick"); var campaign= component.get("v.campaign"); // alert(picklist); // alert(campaign); var createOpportunityEvent = $A.get("e.force:createRecord"); createOpportunityEvent.setParams({ "entityApiName": "Opportunity", "defaultFieldValues": { 'Name' : 'New Opp', 'Type' : 'Existing Customer - Upgrade', 'pcikListTest__c' : picklist, 'CampaignId' : campaign } }); createOpportunityEvent.fire(); }, })
Class :
public class CloneOpp { @AuraEnabled public static Opportunity getDetailsFromOpp(string recordId){ Opportunity opp = [select Id,Name,CampaignId,TrackingNumber__c,pcikListTest__c from Opportunity Where Id = :recordId limit 1]; return opp ; } }
Does anything stand out as out of place ? Any help you can give would be appreciated.
Thank you.
<aura:component controller="CloneOpp" implements="force:lightningQuickActionWithoutHeader,lightning:actionOverride,force:hasRecordId">
Otherwise, recordId will always be undefined.
var recordId = component.get("v.recordId"); //recordId is always undefined without force:hasRecordId interface
if(recordId!=undefined){
........
}
All Answers
queryOpp: function(component, event, helper) {
var self = this;
var recordId = component.get("v.recordId");
........
self.createOppRecord(component, event, helper);
<aura:component controller="CloneOpp" implements="force:lightningQuickActionWithoutHeader,lightning:actionOverride,force:hasRecordId">
Otherwise, recordId will always be undefined.
var recordId = component.get("v.recordId"); //recordId is always undefined without force:hasRecordId interface
if(recordId!=undefined){
........
}
That produced a new error :
Any ideas....?
Also - I just noticed that I added your 'self' to the wrong line - and when I attempted to put it in line 31 of the Helper instead I was unable to save the code. I was given this error :
And I'm also getting this error when attempting to use the Quick Action as well (I didn't notice it at first because it was blocked by the other one) :
here's the full error :
var name= component.get("v.oppName");