0

I have a dynamic picklist (Industry) from Lead in component which is displaying but not Saving.

controller:

public with sharing class RequirementsUX {
    //---- All field data in one method 
    @AuraEnabled 
    Public static string picklistvalues(String recordId){
        Map<String,List<String>> pickoptions = new Map<String,List<String>>();
        pickoptions.put('Home_Type__c',getHomeType());
        pickoptions.put('Scope_Of_Work__c',getScopeOfWork());
        pickoptions.put('Interior_work_needed_for__c',getInteriorworkneededfor());
        pickoptions.put('Property_Usage__c',getPropertyUsage());
        pickoptions.put('Requirement_Details__c',getRequirementDetails());
        pickoptions.put('Civil_Work__c',new list<string>{'true','false'});
        pickoptions.put('LeadRecord',new List<String>{JSON.serialize(Leaddata(recordId))});
        return json.serialize(pickoptions);
    }
    
    //-- Seperate picklist values
    @AuraEnabled 
    public static List<String> getHomeType(){
        Map<String,String> options = new Map<String, String>();
        Schema.DescribeFieldResult fieldResult = Lead.Home_Type__c.getDescribe();
        List<Schema.PicklistEntry> pList = fieldResult.getPicklistValues();
        for (Schema.PicklistEntry p: pList) {
            options.put(p.getValue(), p.getLabel());
        }
        return options.values();
    }
    
    @AuraEnabled 
    public static List<String> getScopeOfWork(){
        // working code - removed to reduce
    }
    
    @AuraEnabled 
    public static List<String> getInteriorworkneededfor(){
        // working code - removed to reduce
    }
    
    @AuraEnabled 
    public static List<String> getPropertyUsage(){
        Map<String, String> options = new Map<String, String>();
        Schema.DescribeFieldResult fieldResult = Lead.Property_Usage__c.getDescribe();
        List<Schema.PicklistEntry> pList = fieldResult.getPicklistValues();
        // working code - removed to reduce
        return options.values();
    } 
    
     @AuraEnabled 
    public static List<String> getRequirementDetails(){
        Map<String, String> options = new Map<String, String>();
        Schema.DescribeFieldResult fieldResult = Lead.Requirement_Details__c.getDescribe();
        List<Schema.PicklistEntry> pList = fieldResult.getPicklistValues();
        for (Schema.PicklistEntry p: pList) {
            options.put(p.getValue(), p.getLabel());
        }
        return options.values();
    }  
    
  @AuraEnabled 
    public static Map<String, String> getIndustryFieldValue(){
        Map<String, String> options = new Map<String, String>();
        
        Schema.DescribeFieldResult fieldResult = Lead.Industry.getDescribe();
        
        List<Schema.PicklistEntry> pValues = fieldResult.getPicklistValues();
        for (Schema.PicklistEntry p: pValues) {
            
            options.put(p.getValue(), p.getLabel());
        }
        return options;
    }   
    
    
    //---- Update Edited Field values
    @AuraEnabled 
    Public static String Updatelead(String leadRec){
        try{
            Lead ld = (Lead)JSON.deserialize(LeadRec, Lead.class);
            update ld; 
            return 'success';
        }catch(Exception e){
            return e.getMessage();
        }
        finally {
        }
    }

    //---- Displaying Existed Data   
    @AuraEnabled
    public static Lead Leaddata(Id recordId) {
        Lead ld = [Select Id,Area__c,Home_Type__c, Scope_Of_Work__c, Civil_Work__c,Interior_work_needed_for__c,Property_Usage__c, 
                  Requirement_Details__c,Move_in__c,Property_Possession_Date__c, Industry from Lead where Id=:recordId LIMIT 1];
        return ld;
    }  
}

Component:

<aura:component implements="flexipage:availableForRecordHome,force:hasRecordId" 
                access="global" 
                controller="RequirementsUX">
    
    <aura:attribute name="LeadRecord" type="object"/>
    <!-- aura attributes to store data/values -->
    <aura:attribute name="ListHomeType" type="List"/>
    <aura:attribute name="ListScopeOfWork" type="List"/>
    <aura:attribute name="ListInteriorworkneededfor" type="List"/>
    <aura:attribute name="ListPropertyUsage" type="List"/>
    <aura:attribute name="ListRequirementDetails" type="List"/>
    <aura:attribute name="ListCivilWork" type="List"/> 
    <aura:attribute name="ListFloorArea" type="String"/>
    
    <aura:attribute name="disablepicklistvalues" type="Boolean" default ="true"/>
    
    <aura:attribute name="HomeType" type="String"/>
    <aura:attribute name="ScopeOfWork" type="String"/>
    <aura:attribute name="Interiorworkneededfor" type="String"/>
    <aura:attribute name="PropertyUsage" type="String"/> 
    <aura:attribute name="RequirementDetails" type="String"/>
    <aura:attribute name="CivilWork" type="String"/>
    <aura:attribute name="FloorArea" type="String"/>
    <aura:attribute name="MoveIn" type="Date"/>
    <aura:attribute name="fieldMap" type="Map"/>
    <aura:attribute name="PropertyPossessionDate" type="Date"/>
    
   <aura:attribute name="ld" type="Lead" default="{'sobjectType':'Lead', 
                                                   'Home_Type__c': '',
                                                   'Scope_Of_Work__c': '',
                                                   'Interior_work_needed_for__c': '',
                                                   'Property_Usage__c': '',
                                                   'Requirement_Details__c': '',
                                                   'Civil_Work__c': '',
                                                   'Area__c': '',
                                                   'Move_in__c': '',
                                                  'Industry': '',
                                                   'Property_Possession_Date__c': ''}"/>
    
    <!--Declare Handler-->
    <aura:handler name="init"  value="{!this}"  action="{!c.doInit}"/> 
    
    <br/>  
    
    <div> Property Type </div>
    <lightning:layout multipleRows="true">
        <lightning:layoutItem size="12" mediumDeviceSize="12" padding="around-small">
            <aura:iteration items="{!v.ListHomeType}" var="HoTy">
                <lightning:button variant="{!if(HoTy.isSelected == true,'brand','brand-outline')}" label="{!HoTy.value}" name="{!HoTy.value}" title="Neutral action" onclick="{! c.homeTypeButtons }" disabled="{!v.disablepicklistvalues}"/>
            </aura:iteration>
        </lightning:layoutItem>
    </lightning:layout>
    
    <div> Floor Area(sqft) </div>
    <lightning:layoutItem size="3" padding="around-small">
    <div class="form-group">  
        <lightning:input name="accName" onChange="{!c.onChangeFA}" type="text" maxlength="50" value="{!v.FloorArea}" disabled="{!v.disablepicklistvalues}"/>
    </div>
    </lightning:layoutItem>
    <br/>
    
    <div> Scope Of Work </div>
    <lightning:layout multipleRows="true">
        <lightning:layoutItem size="12" mediumDeviceSize="12" padding="around-small">
            <aura:iteration items="{!v.ListScopeOfWork}" var="ScofWrk">
                <lightning:button variant="{!if(ScofWrk.isSelected == true,'brand','brand-outline')}" label="{!ScofWrk.value}" name="{!ScofWrk.value}" title="Neutral action" onclick="{! c.ListScopeOfWorkButtons }" disabled="{!v.disablepicklistvalues}"/>
            </aura:iteration>
        </lightning:layoutItem>
    </lightning:layout>
    
    <div> Site Services Work </div>
    <lightning:layout multipleRows="true">
        <lightning:layoutItem size="12" mediumDeviceSize="12" padding="around-small">
           <aura:iteration items="{!v.ListCivilWork}" var="CiWrk">
                <lightning:button variant="{!if(CiWrk.isSelected == true,'brand','brand-outline')}" label="{!CiWrk.value}" name="{!CiWrk.value}" title="Neutral action" onclick="{! c.cwButton }" disabled="{!v.disablepicklistvalues}"/>
            </aura:iteration>
        </lightning:layoutItem>
    </lightning:layout>  
    
    <div> Interior work needed for </div>
    <lightning:layout multipleRows="true">
        <lightning:layoutItem size="12" mediumDeviceSize="12" padding="around-small">
            <aura:iteration items="{!v.ListInteriorworkneededfor}" var="IntWrknedfor">
                <lightning:button variant="{!if(IntWrknedfor.isSelected == true,'brand','brand-outline')}" label="{!IntWrknedfor.value}" name="{!IntWrknedfor.value}" title="Neutral action" onclick="{! c.ListInteriorworkneededforButtons}" disabled="{!v.disablepicklistvalues}"/>
            </aura:iteration>
        </lightning:layoutItem>
    </lightning:layout>
    
    <div> Property Usage </div>
    <lightning:layout multipleRows="true">
        <lightning:layoutItem size="12" mediumDeviceSize="12" padding="around-small">
            <aura:iteration items="{!v.ListPropertyUsage}" var="PropUs">
                <lightning:button variant="{!if(PropUs.isSelected == true,'brand','brand-outline')}" label="{!PropUs.value}" name="{!PropUs.value}" title="Neutral action" onclick="{! c.ListPropertyUsageButtons }" disabled="{!v.disablepicklistvalues}"/>
            </aura:iteration>
        </lightning:layoutItem>
    </lightning:layout>
    
  
    <lightning:layoutItem size="3" padding="around-small">
        
        <div class="slds-grid slds-gutters">
            <div class="slds-col">
       <lightning:input name="accName" onChange="{!c.onChangeMI}" type="date" label="Move-In" maxlength="50" value="{!v.MoveIn}" disabled="{!v.disablepicklistvalues}"/>
       </div>
        <div class="slds-col">
        <lightning:input name="accName" onChange="{!c.onChangePPD}" type="date" label="Property Possession Date" maxlength="50" value="{!v.PropertyPossessionDate}" disabled="{!v.disablepicklistvalues}"/>
        </div>
            </div>
    </lightning:layoutItem>
  
    
    <div> Requirement Details </div>
    <lightning:layout multipleRows="true">
        <lightning:layoutItem size="12" mediumDeviceSize="12" padding="around-small">
            <aura:iteration items="{!v.ListRequirementDetails}" var="ReqDetail">
                <lightning:button variant="{!if(ReqDetail.isSelected == true,'brand','brand-outline')}" label="{!ReqDetail.value}" name="{!ReqDetail.value}" title="Neutral action" onclick="{! c.ListRequirementDetailsButtons }" disabled="{!v.disablepicklistvalues}"/>
            </aura:iteration>
        </lightning:layoutItem>
    </lightning:layout>
    
<div class="form-group">
                <lightning:select aura:id="industryPicklist" value="{!v.ld.Industry}" onchange="{!c.handleOnChange}" name="industryPicklist" label="Industry" >
                    <option value="">--None--</option>
                    <aura:iteration items="{!v.fieldMap}" var="i" indexVar="key">
                        <option text="{!i.value}" value="{!i.key}" selected="{!i.key==v.ld.Industry}" />
                    </aura:iteration>
                </lightning:select>
            </div>    
  
    <div class="slds-align_absolute-center" style="height:5rem">
        <lightning:button label="Edit"  title="Edit" onclick="{! c.handleEdit }"/>
        <lightning:button variant="brand" label="Submit" title="Brand action" onclick="{!c.UpdateLead}" disabled="{!v.disablepicklistvalues}" />
    </div>
</aura:component>

js controller

({
    //Load Lead Picklist values
    doInit: function(component, event, helper) { 
        component.set("v.disablepicklistvalues",true);
        helper.getLeadPicklist(component, event);
         helper.getPicklistValues(component, event);
        
    },
    
    homeTypeButtons : function(cmp, event, helper) {
        var whichOne = event.getSource().get("v.name");
        var HomeTypevalues = cmp.get('v.ListHomeType');
        for (var i = 0; i < HomeTypevalues.length; i++) {
            if(HomeTypevalues[i].value == whichOne){
                HomeTypevalues[i].isSelected = HomeTypevalues[i].isSelected ? false: true;
            }
        }
        cmp.set("v.ListHomeType", HomeTypevalues);
    },
    
    ListScopeOfWorkButtons : function(cmp, event, helper) {
        var whichOne = event.getSource().get("v.name");
        var HomeTypevalues = cmp.get('v.ListScopeOfWork');
        for (var i = 0; i < HomeTypevalues.length; i++) {
            if(HomeTypevalues[i].value == whichOne){
                HomeTypevalues[i].isSelected = HomeTypevalues[i].isSelected ? false: true;
            }
        }
        cmp.set("v.ListScopeOfWork", HomeTypevalues);
    },
    
    ListInteriorworkneededforButtons : function(cmp, event, helper) {
        var whichOne = event.getSource().get("v.name");
        var HomeTypevalues = cmp.get('v.ListInteriorworkneededfor');
        for (var i = 0; i < HomeTypevalues.length; i++) {
            if(HomeTypevalues[i].value == whichOne){
                HomeTypevalues[i].isSelected = HomeTypevalues[i].isSelected ? false: true;
            }
        }
        cmp.set("v.ListInteriorworkneededfor", HomeTypevalues);
    },
    
    ListPropertyUsageButtons : function(cmp, event, helper) {
        var whichOne = event.getSource().get("v.name");
        var HomeTypevalues = cmp.get('v.ListPropertyUsage');
        for (var i = 0; i < HomeTypevalues.length; i++) {
            if(HomeTypevalues[i].value == whichOne){
                HomeTypevalues[i].isSelected = HomeTypevalues[i].isSelected ? false: true;
            }
        }
        cmp.set("v.ListPropertyUsage", HomeTypevalues);
    },
    ListRequirementDetailsButtons : function(cmp, event, helper) {
        var whichOne = event.getSource().get("v.name");
        var HomeTypevalues = cmp.get('v.ListRequirementDetails');
        for (var i = 0; i < HomeTypevalues.length; i++) {
            if(HomeTypevalues[i].value == whichOne){
                HomeTypevalues[i].isSelected = HomeTypevalues[i].isSelected ? false: true;
            }
        }
        cmp.set("v.ListRequirementDetails", HomeTypevalues);
    },
    onChangeFA : function(cmp, event, helper) {
      var FA = event.getSource().get("v.value");  
        cmp.set('v.FloorArea', FA);
    },
    onChangeMI : function(cmp, event, helper) {
      var MI = event.getSource().get("v.value");  
        cmp.set('v.MoveIn', MI);
    },
     onChangePPD : function(cmp, event, helper) {
      var PPD = event.getSource().get("v.value");  
        cmp.set('v.PropertyPossessionDate', PPD);
    },
    cwButton : function(cmp, event, helper) {
        var whichOne = event.getSource().get("v.name");
        var HomeTypevalues = cmp.get('v.ListCivilWork');
        for (var i = 0; i < HomeTypevalues.length; i++) {
            if(HomeTypevalues[i].value == whichOne){
                HomeTypevalues[i].isSelected = true;
            }else{
                HomeTypevalues[i].isSelected = false;
            }
        }
        
        cmp.set("v.ListCivilWork", HomeTypevalues);
    },
    
    
   //handle Industry Picklist Selection
    handleOnChange : function(component, event, helper) {
        var industry = component.get("v.ld.Industry");
        alert(industry);
    },
  

    //--- For Edit Option 
    handleEdit :function(component, event, helper){
        component.set("v.disablepicklistvalues",false); 
    },
    
    // Update All required fields using Submit Button 
    UpdateLead : function(component, event, helper){
            helper.Saveupdatedleadvalues(component, event,helper);  
    }
})

js helper

({
    // Picklist data shown as buttons
    getLeadPicklist: function(component, event) {
        var action = component.get("c.picklistvalues");
        action.setParams({"recordId" : component.get('v.recordId')});
        action.setCallback(this, function(response) {
            var state = response.getState();
            if (state === "SUCCESS") {
                var result = JSON.parse(response.getReturnValue());
                var hometypeFinalValues = [];
                
                var leadRec = JSON.parse(result['LeadRecord']);
                component.set('v.LeadRecord',leadRec);
                component.set("v.HomeType",leadRec['Home_Type__c']);
                component.set("v.ScopeOfWork",leadRec['Scope_Of_Work__c']);
                component.set("v.Interiorworkneededfor",leadRec['Interior_work_needed_for__c']);
                component.set("v.PropertyUsage",leadRec['Property_Usage__c']);
                component.set("v.RequirementDetails",leadRec['Requirement_Details__c']);
                component.set("v.CivilWork",leadRec['Civil_Work__c']);
                component.set("v.FloorArea",leadRec['Area__c']);
                component.set("v.MoveIn",leadRec['Move_in__c']);
                component.set("v.PropertyPossessionDate",leadRec['Property_Possession_Date__c']);
                                
                var HomeTypevalues = result['Home_Type__c'];
                var finalHometypeValues = [];
                for (var i = 0; i < HomeTypevalues.length; i++) {
                    var valueObj={
                        'value':HomeTypevalues[i]
                    };
                    if(leadRec['Home_Type__c'] != undefined && leadRec['Home_Type__c'].includes(HomeTypevalues[i])){
                        valueObj.isSelected = true; 
                    }else{
                        valueObj.isSelected = false; 
                    }
                    finalHometypeValues.push(valueObj);
                }
                
                var Propertyvalues = result['Property_Usage__c'];
                var finalPropertyvalues = [];
                for (var i = 0; i < Propertyvalues.length; i++) {
                    var valueObj={
                        'value':Propertyvalues[i]
                    };
                    if(!!leadRec['Property_Usage__c'] && leadRec['Property_Usage__c'].includes(Propertyvalues[i])){
                        valueObj.isSelected = true; 
                    }else{
                        valueObj.isSelected = false; 
                    }
                    finalPropertyvalues.push(valueObj);
                }
                
                var interiorValues = result['Interior_work_needed_for__c'];
                var finalinteriorValues = [];
                for (var i = 0; i < interiorValues.length; i++) {
                    var valueObj={
                        'value':interiorValues[i]
                    };
                    if(!!leadRec['Interior_work_needed_for__c'] && leadRec['Interior_work_needed_for__c'].includes(interiorValues[i])){
                        valueObj.isSelected = true; 
                    }else{
                        valueObj.isSelected = false; 
                    }
                    finalinteriorValues.push(valueObj);
                }
                
                var Scopevalues = result['Scope_Of_Work__c'];
                var finalScopevalues = [];
                for (var i = 0; i < Scopevalues.length; i++) {
                    var valueObj={
                        'value':Scopevalues[i]
                    };
                    if(!!leadRec['Scope_Of_Work__c'] && leadRec['Scope_Of_Work__c'].includes(Scopevalues[i])){
                        valueObj.isSelected = true; 
                    }else{
                        valueObj.isSelected = false; 
                    }
                    finalScopevalues.push(valueObj);
                }
                
                var ReqDetailsvalues = result['Requirement_Details__c'];
                var finalReqDetailsvalues = [];
                for (var i = 0; i < ReqDetailsvalues.length; i++) {
                    var valueObj={
                        'value':ReqDetailsvalues[i]
                    };
                    if(!!leadRec['Requirement_Details__c'] && leadRec['Requirement_Details__c'].includes(ReqDetailsvalues[i])){
                        valueObj.isSelected = true; 
                    }else{
                        valueObj.isSelected = false; 
                    }
                    finalReqDetailsvalues.push(valueObj);
                }
                
                var CWScopevalues = [];
                
                if(!!leadRec['Civil_Work__c'] && leadRec['Civil_Work__c']){
                    var valueObj={
                        'value':'true',
                        'isSelected':true
                    };
                    var valueObj2={
                        'value':'false',
                        'isSelected':false
                    };
                    CWScopevalues.push(valueObj);
                    CWScopevalues.push(valueObj2);
                }else{
                    var valueObj={
                        'value':'false',
                        'isSelected':true
                    }; 
                    
                    var valueObj2={
                        'value':'true',
                        'isSelected':false
                    }; 
                    CWScopevalues.push(valueObj);
                    CWScopevalues.push(valueObj2);
                }
                             
                
                
                component.set("v.ListHomeType",finalHometypeValues);
                component.set("v.ListScopeOfWork",finalScopevalues);
                component.set("v.ListInteriorworkneededfor",finalinteriorValues);
                component.set("v.ListPropertyUsage",finalPropertyvalues);
                component.set("v.ListRequirementDetails",finalReqDetailsvalues);
                component.set("v.ListCivilWork",CWScopevalues);
                component.set("v.FloorArea",leadRec['Area__c']);
                component.set("v.MoveIn",leadRec['Move_in__c']);
                component.set("v.PropertyPossessionDate",leadRec['Property_Possession_Date__c']);
            }
        });
        $A.enqueueAction(action);
    },
    
    
    getPicklistValues: function(component, event) {
        var action = component.get("c.getIndustryFieldValue");
        action.setCallback(this, function(response) {
            var state = response.getState();
            if (state === "SUCCESS") {
                var result = response.getReturnValue();
                var fieldMap = [];
                for(var key in result){
                    fieldMap.push({key: key, value: result[key]});
                }
                component.set("v.fieldMap", fieldMap);
            }
        });
        $A.enqueueAction(action);
    },
  
    
       
    // Submit to save the updated values in leads
    Saveupdatedleadvalues: function(component,event,helper){
  
        var leadRec = component.get("v.LeadRecord");
        var hometypeArray = component.get("v.ListHomeType");
        var scopeOfWorkArray =  component.get("v.ListScopeOfWork");
        var interiorArray =  component.get("v.ListInteriorworkneededfor");
        var propertyArray = component.get("v.ListPropertyUsage");
        var RequirementArray = component.get("v.ListRequirementDetails");
        var civilWorkArray = component.get("v.ListCivilWork");
        var hometype = null;
        for(var i=0;i<hometypeArray.length;i++){
            if(hometypeArray[i].isSelected){
                if(!!hometype){
                    hometype = hometype+';'+hometypeArray[i].value;
                }else{
                    hometype = hometypeArray[i].value;
                }
            }
        }
        
        var scopeOfWork = null;
        for(var i=0;i<scopeOfWorkArray.length;i++){
            if(scopeOfWorkArray[i].isSelected){
                if(!!scopeOfWork){
                    scopeOfWork = scopeOfWork+';'+scopeOfWorkArray[i].value;
                }else{
                    scopeOfWork = scopeOfWorkArray[i].value;
                }
            }
        }
        
        var interior = null;
        for(var i=0;i<interiorArray.length;i++){
            if(interiorArray[i].isSelected){
                if(!!interior){
                    interior = interior+';'+interiorArray[i].value;
                }else{
                    interior = interiorArray[i].value;
                }
            }
        }
        
        var property = null;
        for(var i=0;i<propertyArray.length;i++){
            if(propertyArray[i].isSelected){
                if(!!property){
                    property = property+';'+propertyArray[i].value;
                }else{
                    property = propertyArray[i].value;
                }
            }
        }
        
         var Requirement = null;
        for(var i=0;i<RequirementArray.length;i++){
            if(RequirementArray[i].isSelected){
                if(!!Requirement){
                    Requirement = Requirement+';'+RequirementArray[i].value;
                }else{
                    Requirement = RequirementArray[i].value;
                }
            }
        }
        
        var civilWork = false;
        for(var i=0;i<civilWorkArray.length;i++){
            if(civilWorkArray[i].isSelected){
                civilWork = civilWorkArray[i].value;
            }
        }
        leadRec['Home_Type__c'] = hometype;
        leadRec['Scope_Of_Work__c'] = scopeOfWork;
        leadRec['Interior_work_needed_for__c'] = interior;
        leadRec['Property_Usage__c'] = property;
        leadRec['Requirement_Details__c'] = Requirement;
        leadRec['Civil_Work__c'] =civilWork;
        leadRec['Area__c'] =component.get('v.FloorArea');
        leadRec['Move_in__c'] =component.get('v.MoveIn');
        leadRec['Property_Possession_Date__c'] =component.get('v.PropertyPossessionDate');
        var action = component.get("c.Updatelead");
           action.setParams({
            "leadRec" : JSON.stringify(leadRec)
        });
        action.setCallback(this, function(response) {
            var state = response.getState();
            if (state === "SUCCESS") {
                var result = response.getReturnValue();
                helper.showSuccess(component, event, helper);
            }
        });
        $A.enqueueAction(action);
    },
    
    showError : function(component, event, helper) {
        var toastEvent = $A.get("e.force:showToast");
        toastEvent.setParams({
            title : 'Error',
            message: 'Not Updated Successfully',
            duration:' 5000',
            key: 'info_alt',
            type: 'error',
            mode: 'pester'
        });
        toastEvent.fire();
        component.set("v.disablepicklistvalues",true); 
    },
    showSuccess : function(component, event, helper) {
        var toastEvent = $A.get("e.force:showToast");
        toastEvent.setParams({
            title : 'Success',
            message: 'Updated Successfully',
            duration:' 5000',
            key: 'info_alt',
            type: 'success',
            mode: 'pester'
        });
        toastEvent.fire();
        component.set("v.disablepicklistvalues",true);
    }
})
2

1 Answer 1

2

We shouldn't have identical method names in client controller.js & apex controller. What exactly happens here is component.get("c.Updatelead") returns reference to your client-side controller Updatelead method & enqueues it & perhaps the apex controller method is never called.

To fix this you should either update your apex controller & update the method name to something else than Updatelead, perhaps updateLeadRecord, then make change in your helper.js to call the updated method.

@AuraEnabled
public static String updateLeadRecord(String leadRec){}

const action = component.get("c.updateLeadRecord");
   action.setParams({
    "leadRec" : JSON.stringify(leadRec)
});
1
  • Thanks. Got this to work.
    – Col
    Commented Apr 4, 2022 at 4:20

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .