You need to sign in to do that
Don't have an account?
System Admin 949
Clone Button not working in Lightning Components
Hi all,
I created the lightning component for clone the quote record .i added this component in vf page and call that vf page through custom button.
but its not working.any one can guide me how to do this.my code is
apex controller
public class QuoteController {
@AuraEnabled
public static Quote getDetailsFromQuote(string recordId){
Quote q = [select Id,Name,AccountId,ContactId,OpportunityId
from Quote Where Id = :recordId limit 1];
return q;
}
}
component
<aura:component controller="QuoteController" implements="force:lightningQuickActionWithoutHeader,lightning:actionOverride">
<meta name="viewport" condoInittent="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="QuoteName" type="String" />
<aura:attribute name="account" type="String" />
<aura:attribute name="contact" type="String" />
<aura:attribute name="opportunity" 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.js
({
doInit: function(component, event, helper) {
var recordId = component.get("v.recordId");
if(recordId!=undefined){
alert(recordId);
var action = component.get("c.getDetailsFromQuote");
action.setParams({
recordId: recordId
});
action.setCallback(this, function(response){
var state = response.getState();
if (state === "SUCCESS") {
var q = response.getReturnValue();
component.set("v.QuoteName", q.Name);
component.set("v.account", q.AccountId);
component.set("v.contact", q.ContactId);
component.set("v.opportunity", q.OpportunityId);
helper.createQuoteRecord(component, event, helper);
}
});
$A.enqueueAction(action);
}
},
createQuoteRecord : function (component, event, helper) {
var name= component.get("v.QuoteName");
var account = component.get("v.account");
var contact= component.get("v.contact");
var opportunity= component.get("v.opportunity");
// alert(picklist);
// alert(campaign);
var createQuoteEvent = $A.get("e.force:createRecord");
createQuoteEvent.setParams({
"entityApiName": "Quote",
"defaultFieldValues": {
'Name' : 'New Quote',
'AccountId' : account,
'ContactId' : contact,
'OpportunityId' : opportunity
}
});
createQuoteEvent.fire();
},
})
helper.js
({
doInit: function(component, event, helper) {
//call the helper function with pass [component, Controller field and Dependent Field] Api name
// alert('Hi');
helper.doInit(component, event, helper);
},
})
lightning app
<aura:application access="GLOBAL" extends="ltng:outApp">
<aura:dependency resource="c:QuoteComponent"/>
</aura:application>
vf page
<!--<apex:page standardController="Quote"
extensions="QuoteCloneController" action="{!cloneWithItems}">
<apex:pageMessages />
</apex:page>-->
<apex:page >
<apex:includeLightning />
<div style="width:30%;height:100px;" id="FlipcardContainer" />
<script>
$Lightning.use("c:QuoteApp", function() {
$Lightning.createComponent("c:QuoteComponent",
{
borderColor : "#16325c",
bgColor : "#16325c" ,
fontColor : "#FFF",
frontText : "What's cool about Lightning Component Development",
backText : "You dont need to enable Lightning experience, It will work on Classic Instance as well"
},
"FlipcardContainer",
function(cmp) {
console.log('Component created, do something cool here');
});
});
</script>
</apex:page>
very urgent for this clone button.any one can provide the solution.
thanks in advance
I created the lightning component for clone the quote record .i added this component in vf page and call that vf page through custom button.
but its not working.any one can guide me how to do this.my code is
apex controller
public class QuoteController {
@AuraEnabled
public static Quote getDetailsFromQuote(string recordId){
Quote q = [select Id,Name,AccountId,ContactId,OpportunityId
from Quote Where Id = :recordId limit 1];
return q;
}
}
component
<aura:component controller="QuoteController" implements="force:lightningQuickActionWithoutHeader,lightning:actionOverride">
<meta name="viewport" condoInittent="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="QuoteName" type="String" />
<aura:attribute name="account" type="String" />
<aura:attribute name="contact" type="String" />
<aura:attribute name="opportunity" 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.js
({
doInit: function(component, event, helper) {
var recordId = component.get("v.recordId");
if(recordId!=undefined){
alert(recordId);
var action = component.get("c.getDetailsFromQuote");
action.setParams({
recordId: recordId
});
action.setCallback(this, function(response){
var state = response.getState();
if (state === "SUCCESS") {
var q = response.getReturnValue();
component.set("v.QuoteName", q.Name);
component.set("v.account", q.AccountId);
component.set("v.contact", q.ContactId);
component.set("v.opportunity", q.OpportunityId);
helper.createQuoteRecord(component, event, helper);
}
});
$A.enqueueAction(action);
}
},
createQuoteRecord : function (component, event, helper) {
var name= component.get("v.QuoteName");
var account = component.get("v.account");
var contact= component.get("v.contact");
var opportunity= component.get("v.opportunity");
// alert(picklist);
// alert(campaign);
var createQuoteEvent = $A.get("e.force:createRecord");
createQuoteEvent.setParams({
"entityApiName": "Quote",
"defaultFieldValues": {
'Name' : 'New Quote',
'AccountId' : account,
'ContactId' : contact,
'OpportunityId' : opportunity
}
});
createQuoteEvent.fire();
},
})
helper.js
({
doInit: function(component, event, helper) {
//call the helper function with pass [component, Controller field and Dependent Field] Api name
// alert('Hi');
helper.doInit(component, event, helper);
},
})
lightning app
<aura:application access="GLOBAL" extends="ltng:outApp">
<aura:dependency resource="c:QuoteComponent"/>
</aura:application>
vf page
<!--<apex:page standardController="Quote"
extensions="QuoteCloneController" action="{!cloneWithItems}">
<apex:pageMessages />
</apex:page>-->
<apex:page >
<apex:includeLightning />
<div style="width:30%;height:100px;" id="FlipcardContainer" />
<script>
$Lightning.use("c:QuoteApp", function() {
$Lightning.createComponent("c:QuoteComponent",
{
borderColor : "#16325c",
bgColor : "#16325c" ,
fontColor : "#FFF",
frontText : "What's cool about Lightning Component Development",
backText : "You dont need to enable Lightning experience, It will work on Classic Instance as well"
},
"FlipcardContainer",
function(cmp) {
console.log('Component created, do something cool here');
});
});
</script>
</apex:page>
very urgent for this clone button.any one can provide the solution.
thanks in advance
thanks in avance
https://www.krogerfeedback.us