+ Start a Discussion
ChiyanChiyan 

Create lightning component that contains button On campain member page which calls action to create new Campaign member record populating few field values from existing cm record in another campaign as shown in following picture

User-added image
Meghna Vijay 7Meghna Vijay 7
Hi Chiyan,
There is a similar post on which i commented:-
https://developer.salesforce.com/forums/ForumsMain?id=9062I000000g9GgQAI
Thanks
ChiyanChiyan
Hi Meghna,

Can you provide me full code 


Thanks 
Chiyan.
Meghna Vijay 7Meghna Vijay 7
<aura:component implements="force:lightningquickAction" >
    <aura:handler name="init" value="{!this}" action="{!c.doInit}"/>
</aura:component>

Controller.js
doInit : function(component,event) {
    var createRecEvent = $A.get("e.force:createRecord");
    createRecEvent.setParams({"defaultFieldValues": }); // For more info go through salesforce documentation.
    createRecEvent.fire();
}
Hope it helps, if it does, mark it as solved.
Thanks
 
Saravanan RajarajanSaravanan Rajarajan
Hi Chiyan,

Try This Code,

Component:
 
<aura:component implements="forceCommunity:availableForAllPageTypes,force:lightningquickAction" access="global" >
<aura:handler name="init" value="{!this}" action="{!c.createrecordCamp}"/> 
</aura:component>

Controller.js:

 
createrecordCamp : function(component, event, helper) {
        var createRecordEvent = $A.get('e.force:createRecord');
        createRecordEvent.setParams({
            'entityApiName': Campaign,
                        
            'defaultFieldValues': {                              
                'Name':'Tester',
                'Description':'Test Description',    //populating few field values
            }                
        });
        createRecordEvent.fire();
    },

Please mark it best answer if it helps you.

if you want dynamic value populating please refer i commented:
https://developer.salesforce.com/forums/ForumsMain?id=9062I000000g9GgQAI