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
Leo DarkstarLeo Darkstar 

How to set this field value in a Component

I've made a action button to call a Component in order to clone a record. The component basically takes a bunch of values from the current record and maps them to the new record. I'm also trying to populate a checkbox field to TRUE (or 1). But I'm having trouble populating the field.

Here is the Component :

<aura:component controller="CloneOpp" implements="force:lightningQuickActionWithoutHeader,lightning:actionOverride,force:hasRecordId">
    <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:attribute name="clone" type="boolean" />
     <aura:dependency resource="c:createRecord"/>
    <!-- Load the navigation events in the force namespace. -->
    <aura:dependency resource="markup://force:*" type="EVENT"/>

Here is the Helper of the component :

        queryOpp: function(component,  event, helper) {
        //var self = this;  
        var recordId = component.get("v.recordId");
            var action = component.get("c.getDetailsFromOpp");
                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.campaign", opp.CampaignId);
                    helper.createOppRecord(component, event, helper);
         createOppRecord : function (component, event, helper) {
           var name=  component.get("v.oppName"); 
           var campaign=  component.get("v.campaign");
           var clone= 1; 
        var createOpportunityEvent = $A.get("e.force:createRecord");
        "entityApiName": "Opportunity",
        "defaultFieldValues": {
            'Name' : 'New Opp',
            'CampaignId' : campaign,
            'Clone__c' : clone,   

All I want to do is have the Clone__c field set to 1 or TRUE.

Thank you for any help.

David Zhu 🔥David Zhu 🔥
Can you try replacing line 40 in helper method createOppRecord to 

'Clone__c' : true
Leo DarkstarLeo Darkstar

yha, I've tried that, but the field doesn't appear populated. The checkbox is still unchecked. 

I think you may have helped me with another aspect of this a while back. Thanks for your input. 

Leo DarkstarLeo Darkstar

oh god - I saw what it was. I only had one underscore in 'Clone__c'. 


Btw - your suggestion worked, but so did the original with the variable. What a waste of time. 


Thanks again David.