• lnalluri
  • NEWBIE
  • 260 Points
  • Member since 2019

  • Chatter
    Feed
  • 8
    Best Answers
  • 0
    Likes Received
  • 1
    Likes Given
  • 0
    Questions
  • 30
    Replies
I am trying to show an edit pop up when someone clicks on the icon shown with aura iteration. Below is my code -

<aura:iteration items="{!v.campaign.Campaign_Members__r}" var="cm">
<tr>
   <td class="slds-text-align_center">
   <div id="{!cm.Id}" class="{!'btn-editStatus cmId-'+cm.Id}" onclick="{!c.handleEdit}">
          <lightning:icon size="x-small" iconName="utility:edit"/>  
   </div>
   </td>
</tr>
</aura:iteration>

How should I get the Id of the record (cm.Id) in the handleEdit function in the lightning controller?
Dear Team ,

I created component to insert data , command ran successfully but component not appears in any App Builder (Home,Record,App). However i created component for slider, to delete and update records that components appears in app Builder . Kindly have a look on my code and plz provide me some solution .

Or  Please send me some code through which i am able to unserstand how data will get inserted through LWC 

1)Apex Class:

public inherited sharing class LWCExampleController { @AuraEnabled public static void saveAccountRecord(Account objAcc){ try{ insert objAcc; } catch(Exception ex) { throw new AuraHandledException(ex.getMessage()); } } }

2)createRecordInLWC.html:

<template>
    <lightning-card title="Create Account Record" icon-name="standard:account">
        <div style="margin-left: 6%" if:true={error}>
            <lightning-badge label={error} style="color: red;"></lightning-badge>
        </div>
        <template if:true={accRecord}>
            <div class="slds-m-around--xx-large">
                <div class="container-fluid">
                    <div class="form-group">
                        <lightning-input label="Enter Account Name" name="accName" required="required" type="text" value={accRecord.Name} onchange={handleNameChange}></lightning-input>
                    </div>
                    <div class="form-group">
                        <lightning-input label="Enter Phone Number" name="accPhone" type="number" value={accRecord.Phone} onchange={handlePhoneChange}></lightning-input>
                    </div>
                    <div class="form-group">
                        <lightning-input label="Enter Account Type" name="accEmail" required="required" type="text" value={accRecord.Type} onchange={handleTypeChange}></lightning-input>
                    </div>
                    <div class="form-group">
                        <lightning-input label="Enter Industry" name="accEmail" type="text" value={accRecord.Industry} onchange={handleIndustryChange}></lightning-input>
                    </div>
                </div>
                <br/>
                <lightning-button label="Submit" onclick={handleSave} variant="brand"></lightning-button>
            </div>
        </template>
    </lightning-card>
</template>

3)createRecordInLWC.js:

import { LightningElement, track} from 'lwc';
// Importing Apex Class method
import saveAccount from '@salesforce/apex/LWCExampleController.saveAccountRecord';
// importing to show toast notifictions
import {ShowToastEvent} from 'lightning/platformShowToastEvent';
// importing Account fields
import NAME_FIELD from '@salesforce/schema/Account.Name';
import Phone_FIELD from '@salesforce/schema/Account.Phone';
import Industry_FIELD from '@salesforce/schema/Account.Industry';
import Type_FIELD from '@salesforce/schema/Account.Type';
export default class CreateRecordInLWC extends LightningElement {
    @track error;
    // this object have record information
    @track accRecord = {
        Name : NAME_FIELD,
        Industry : Industry_FIELD,
        Phone : Phone_FIELD,
        Type : Type_FIELD
    };

    handleNameChange(event) {
        this.accRecord.Name = event.target.value;
        window.console.log('Name ==> '+this.accRecord.Name);
    }
    handlePhoneChange(event) {
        this.accRecord.Phone = event.target.value;
        window.console.log('Phone ==> '+this.accRecord.Phone);
    }
    handleTypeChange(event) {
        this.accRecord.Type = event.target.value;
        window.console.log('Type ==> '+this.accRecord.Type);
    }
    handleIndustryChange(event) {
        this.accRecord.Industry = event.target.value;
        window.console.log('Industry ==> '+this.accRecord.Industry);
    }

    handleSave() {
        saveAccount({objAcc: this.accRecord})
        .then(result => {
            // Clear the user enter values
            this.accRecord = {};
            window.console.log('result ===> '+result);
            // Show success messsage
            this.dispatchEvent(new ShowToastEvent({
                title: 'Success!!',
                message: 'Account Created Successfully!!',
                variant: 'success'
            }),);
        })
        .catch(error => {
            this.error = error.message;
        });
    }
}

4)createRecordInLWC.js.meta-xml
<?xml version="1.0" encoding="UTF-8"?>
<LightningComponentBundle xmlns="http://soap.sforce.com/2006/04/metadata" fqn="CreateRecordInLWC">
    <apiVersion>46.0</apiVersion>
    <isExposed>false</isExposed>
     <targets>
       <target>lightning__AppPage</target>
       <target>lightning__RecordPage</target>
       <target>lightning__HomePage</target>
   </targets>
</LightningComponentBundle>


Thanks & Regards
Sachin Bhalerao
So, I have a lightning web component that calls an APEX method to return something.  When I try to display what the APEX returns, I always get [object Object] in the html.

Here's the code:
//.js....
import { LightningElement, api, wire } from 'lwc';
import acceptRtnSomthing from '@salesforce/apex/HelperAccount.acceptRtnSomthing';

export default class UltimateParentMRR extends LightningElement {
    @api recordId;
    somethingReturned = "Value in .js....";
    
    @wire(acceptRtnSomthing, {recId : '$recordId' })
        somethingReturned;

}




// HTML....
<template>
    <lightning-card title="Ultimate Parent MRR" icon-name="standard:account">
        <div class="slds-m-around_medium">
            {somethingReturned}
        </div>
    </lightning-card>
</template>


// APEX...
@AuraEnabled (cacheable=true)
	public static string acceptRtnSomthing(string recId){
		return recId;
	}
If I comment out the call to the APEX - I get "Value in .js...." in the HTML output.

Does anybody see my issue?

Thanks!
 
I am receiving the error:
Unexpected file found in package directory:
When I try to deploy a class that I have just created.  The file is saved in the /force-app/main/default/classes/Case_Trigger_Alert_Count.

I have also noticed that in the 'Problems' tab, I have the message:
The sourcepath ".../force-app/main/default/classes/Case_Trigger_Alert_Count" is not a valid source file path.  SourcePathInvalid [1,1]

The filename of the file I have just created and attempting to deploy is 'Case_Trigger_Alert_Count"
What am I missing to be able to deploy to my Sandbox?
Hello All,
I'm extremely new to lightning components and trying to replace some of our custom javascript buttons with lightning compatible options.  One button takes ownership of a lead.  I found a post that does something similar for cases and tried to modify it for my purpose: https://learnownlightning.blogspot.com/2018/01/change-owner-update-record-using.html

It seems to be doing the record update based on apex code, but it launches a quickaction screen with a cancel button that doens't go away.  I've seen it posted that you can use 
$A.get("e.force:closeQuickAction").fire();
It is not working for me.  I'm not sure if I'm not puting that code in the right place but I'm hoping someone can help me figure out a way to click the quick action button, have the lead change ownership, and that's it.

Here is my code so far:
Component:
<aura:component implements="force:lightningQuickAction,force:hasRecordId" controller="LightningComponent_MoveToMarketing" access="global" >
<aura:handler name="init" value="{!this}" action="{!c.doInit}"/>    
</aura:component>
Controller:
({
 doInit : function(component, event, helper) {
        var leadId = component.get("v.recordId");
        var action = component.get("c.changeOwnerMethod");
        action.setParams({
            leadId : leadId
        });
        action.setCallback(this, function(response) {
            if(response.getState() === "SUCCESS") {
                console.log("Lead Owner Changed To Current login User");
             var rec = response.getReturnValue();
             console.log(rec.OwnerId);
            }
        });
        $A.enqueueAction(action);
$A.get("e.force:closeQuickAction").fire();
        $A.get('e.force:refreshView').fire();
 }
})

Apex Class:
public class LightningComponent_MoveToMarketing {

    @AuraEnabled
    public static Lead changeOwnerMethod(Id leadId) {
        if(leadId != null) {
            Lead l = [SELECT OwnerId FROM Lead WHERE Id = :leadId];
         l.OwnerId = UserInfo.getUserId();
//update case Ownerid with loggedin userid.
            update l;
            return l;
        }
        return null;
    }

}

Any ideas?
 
Hello,

I am geeting a substring like below
strText = strText.substring(0,10);
How can i make it 10 characters if the str text is less than 9 characters.

Thank you for suggestion !


 
Hi,

As My code runs perfect but as per salesforce limit getting an error.

@RestResource(urlMapping='/leadactivity/getlist/*')
global with sharing  class myActivityTask {
    
    @HttpGet
    global static  list<cust_map> doGetLead(){
        
        list<task> activityLog=new list<task> ();
        
        RestRequest req = RestContext.request;
        RestResponse res = RestContext.response;
        map<string,string> paramsMap=RestContext.request.params;
        string actdate=paramsMap.get('actdate');
        Datetime dt1 = Datetime.valueOf(actdate);
        list<cust_map> results = new list<cust_map>();        
        list<Task> taskList=[SELECT WhoId,Five9__Five9AgentName__c,createdDate,CompletedDateTime,Id,who.type FROM Task where CreatedDate>:dt1];
    

        for(task str:taskList){
            cust_map obj = new cust_map();
            if(str.who.type!='Lead')
                continue;
            
            Lead result = [SELECT SId__c FROM Lead WHERE Id = :str.WhoId];

            obj.LeadID =     str.WhoId;
            obj.CallCenterAgent = str.Five9__Five9AgentName__c;
            obj.CallDateTime = str.CompletedDateTime;
            obj.LMSID = result.LMSId__c;
            results.add(obj);
        }
       
        return results;
    }
    global class cust_map{
        Global String LeadID=null;
        Global String CallCenterAgent=null;
        Global Datetime CallDateTime=null;
        Global String LMSID = null;
    }
}

Any suggestions how to fix this.

 
I am trying to show an edit pop up when someone clicks on the icon shown with aura iteration. Below is my code -

<aura:iteration items="{!v.campaign.Campaign_Members__r}" var="cm">
<tr>
   <td class="slds-text-align_center">
   <div id="{!cm.Id}" class="{!'btn-editStatus cmId-'+cm.Id}" onclick="{!c.handleEdit}">
          <lightning:icon size="x-small" iconName="utility:edit"/>  
   </div>
   </td>
</tr>
</aura:iteration>

How should I get the Id of the record (cm.Id) in the handleEdit function in the lightning controller?
Dear Team ,

I created component to insert data , command ran successfully but component not appears in any App Builder (Home,Record,App). However i created component for slider, to delete and update records that components appears in app Builder . Kindly have a look on my code and plz provide me some solution .

Or  Please send me some code through which i am able to unserstand how data will get inserted through LWC 

1)Apex Class:

public inherited sharing class LWCExampleController { @AuraEnabled public static void saveAccountRecord(Account objAcc){ try{ insert objAcc; } catch(Exception ex) { throw new AuraHandledException(ex.getMessage()); } } }

2)createRecordInLWC.html:

<template>
    <lightning-card title="Create Account Record" icon-name="standard:account">
        <div style="margin-left: 6%" if:true={error}>
            <lightning-badge label={error} style="color: red;"></lightning-badge>
        </div>
        <template if:true={accRecord}>
            <div class="slds-m-around--xx-large">
                <div class="container-fluid">
                    <div class="form-group">
                        <lightning-input label="Enter Account Name" name="accName" required="required" type="text" value={accRecord.Name} onchange={handleNameChange}></lightning-input>
                    </div>
                    <div class="form-group">
                        <lightning-input label="Enter Phone Number" name="accPhone" type="number" value={accRecord.Phone} onchange={handlePhoneChange}></lightning-input>
                    </div>
                    <div class="form-group">
                        <lightning-input label="Enter Account Type" name="accEmail" required="required" type="text" value={accRecord.Type} onchange={handleTypeChange}></lightning-input>
                    </div>
                    <div class="form-group">
                        <lightning-input label="Enter Industry" name="accEmail" type="text" value={accRecord.Industry} onchange={handleIndustryChange}></lightning-input>
                    </div>
                </div>
                <br/>
                <lightning-button label="Submit" onclick={handleSave} variant="brand"></lightning-button>
            </div>
        </template>
    </lightning-card>
</template>

3)createRecordInLWC.js:

import { LightningElement, track} from 'lwc';
// Importing Apex Class method
import saveAccount from '@salesforce/apex/LWCExampleController.saveAccountRecord';
// importing to show toast notifictions
import {ShowToastEvent} from 'lightning/platformShowToastEvent';
// importing Account fields
import NAME_FIELD from '@salesforce/schema/Account.Name';
import Phone_FIELD from '@salesforce/schema/Account.Phone';
import Industry_FIELD from '@salesforce/schema/Account.Industry';
import Type_FIELD from '@salesforce/schema/Account.Type';
export default class CreateRecordInLWC extends LightningElement {
    @track error;
    // this object have record information
    @track accRecord = {
        Name : NAME_FIELD,
        Industry : Industry_FIELD,
        Phone : Phone_FIELD,
        Type : Type_FIELD
    };

    handleNameChange(event) {
        this.accRecord.Name = event.target.value;
        window.console.log('Name ==> '+this.accRecord.Name);
    }
    handlePhoneChange(event) {
        this.accRecord.Phone = event.target.value;
        window.console.log('Phone ==> '+this.accRecord.Phone);
    }
    handleTypeChange(event) {
        this.accRecord.Type = event.target.value;
        window.console.log('Type ==> '+this.accRecord.Type);
    }
    handleIndustryChange(event) {
        this.accRecord.Industry = event.target.value;
        window.console.log('Industry ==> '+this.accRecord.Industry);
    }

    handleSave() {
        saveAccount({objAcc: this.accRecord})
        .then(result => {
            // Clear the user enter values
            this.accRecord = {};
            window.console.log('result ===> '+result);
            // Show success messsage
            this.dispatchEvent(new ShowToastEvent({
                title: 'Success!!',
                message: 'Account Created Successfully!!',
                variant: 'success'
            }),);
        })
        .catch(error => {
            this.error = error.message;
        });
    }
}

4)createRecordInLWC.js.meta-xml
<?xml version="1.0" encoding="UTF-8"?>
<LightningComponentBundle xmlns="http://soap.sforce.com/2006/04/metadata" fqn="CreateRecordInLWC">
    <apiVersion>46.0</apiVersion>
    <isExposed>false</isExposed>
     <targets>
       <target>lightning__AppPage</target>
       <target>lightning__RecordPage</target>
       <target>lightning__HomePage</target>
   </targets>
</LightningComponentBundle>


Thanks & Regards
Sachin Bhalerao
Component
<aura:if isTrue="{!v.leadRecord.Company!=null}">
            <div class="slds-form-element">
                <label class="slds-form-element__label" for="text-input-id-1">Company</label>
                <div class="slds-form-element__control">
                    <input type="text" aura:id="company" placeholder="" value="{!v.leadRecord.Company}" disabled="true" class="slds-input" />
                </div>
            </div>
            <aura:set attribute="else">
                <lightning:input aura:id="company" label="Company Name" required="true" value="{!v.company}"/>
            </aura:set>
        </aura:if>

JS
var company = component.find("company").get("v.value");

 
Hello, I'm a new developer in general, so I really appreciate the help in advance. 

I wrote a batch job that works great in sandbox, but fails in production becuase I have over 500k Opportunitites.  So I get the old too many queries error.  

I was told that I have to put my query in the START method, so that it wil batch the query itself.  Right now, my EXECUTE method calls the class below to do the queries.  What I need help with is that currently I'm usuing two queries and I'm unsure how to put them both into the start method.  

Here is my class that is called from EXECUTE and fails:

public class ProjectionsBatchCalculations {
    
    static date startDate;
    static integer thisYear;
    
    public static void processCalculations(List<Projections__c> proj){
        
        List<Opportunity> apiSubs = new List<Opportunity>();
        List<Projections__c> toUpdate = new List<Projections__c>();
        List<Opportunity> apisubs2018 = new List<Opportunity>();
        List<Opportunity> apiSubs2019 = new List<Opportunity>();
        
        
        for(Projections__c ps : proj){
            
            integer month = ps.Projection_Term_Start_Date__c.month();
            startDate = ps.Projection_Term_Start_Date__c;
            
            for(Opportunity o : [SELECT id,Date_Received__c FROM Opportunity WHERE API_Submission__c = true 
                                 AND Date_Received__c >= 2018-01-01
                                 AND Account.id =: ps.Related_Account__c]){
                                     
              integer year = o.Date_Received__c.year();
                integer oMonth = o.Date_Received__c.month();
                                                         
                if(oMonth==month){
                                         
                  if(year == 2019) {
                    
                        apiSubs2019.add(o);
                    
                    }else if(year == 2018){
                    
                        apiSubs2018.add(o);
                        }  
                                         
                                         
                    }
                                  

            }
            
            
            system.debug('The apiSubs2018 are' +apiSubs2018);
            system.debug('The apiSubs2019 are' +apiSubs2019);
            ps.X2019_API_Submissions__c = apiSubs2019.size();
            ps.X2018_API_Submissions__c = apiSubs2018.size();
            toUpdate.add(ps);
            apiSubs2019.clear();
            apiSubs2018.clear();
        }
        
        system.debug('The list toUpdate is:' +toUpdate);
        update toUpdate;
        
    }
    
}

As you can see, I have a custom object called Projections__c, of which there arent' many records.  That object has a lookup to Account.  I only want to get the Opptys that match Accounts with Projections__c records.  

Please help!!  

I tried to do something like this:

global class ProjectionsBatchClass implements Database.Batchable<sObject>, Database.Stateful{
   
    global List<Opportunity> releventOpptys = new List<Opportunity>();
    global static List<Projections__c> proj = [SELECT id, Related_Account__c, Projection_Term_Start_Date__c FROM Projections__c];
    global final string query;
    
    
    global ProjectionsBatchClass(){
    
        query = 'SELECT id,Date_Received__c FROM Opportunity WHERE API_Submission__c = true AND Date_Received__c >= 2018-01-01 AND Account.id In: proj.Related_Account__c';
        
        
    } 
    

    
    global Database.QueryLocator start(Database.BatchableContext bc){
      
   
      return Database.getQueryLocator(query);


    } 
    
    global void execute(Database.BatchableContext bc, List<Opportunity> proj){
         
          releventOpptys.addAll(proj);  
          ProjectionsBatchCalculations.processCalculations(releventOpptys);          
    }    


But this fails becuase "proj.Realted_Account__c" is not found.  It's not in scope of the Start method.  

I'm stuck!

 
I am trying to execute below basic SOQL and i get error. 

SELECT Id,(SELECT Id FROM Events) FROM User


Error - 
SELECT Id,(SELECT Id FROM Events) FROM User
                          ^
ERROR at Row:1:Column:27
Didn't understand relationship 'Events' in FROM part of query call. If you are attempting to use a custom relationship, be sure to append the '__r' after the custom relationship name. Please reference your WSDL or the describe call for the appropriate names.
So, I have a lightning web component that calls an APEX method to return something.  When I try to display what the APEX returns, I always get [object Object] in the html.

Here's the code:
//.js....
import { LightningElement, api, wire } from 'lwc';
import acceptRtnSomthing from '@salesforce/apex/HelperAccount.acceptRtnSomthing';

export default class UltimateParentMRR extends LightningElement {
    @api recordId;
    somethingReturned = "Value in .js....";
    
    @wire(acceptRtnSomthing, {recId : '$recordId' })
        somethingReturned;

}




// HTML....
<template>
    <lightning-card title="Ultimate Parent MRR" icon-name="standard:account">
        <div class="slds-m-around_medium">
            {somethingReturned}
        </div>
    </lightning-card>
</template>


// APEX...
@AuraEnabled (cacheable=true)
	public static string acceptRtnSomthing(string recId){
		return recId;
	}
If I comment out the call to the APEX - I get "Value in .js...." in the HTML output.

Does anybody see my issue?

Thanks!
 
Method containing custom exception
/*
public static decimal CelsiusToKelvin (decimal degree)
    {
        if(degree<-273.16)
        { result = -273.16;
           throw new InvalidDataException('Value cannot be less than -273.16');
        }
}

*/

My Test method
class TemperatureTest {
@isTest static void testCelsiusToKelvin()
{
//What to do here?
}
}
 
I am receiving the error:
Unexpected file found in package directory:
When I try to deploy a class that I have just created.  The file is saved in the /force-app/main/default/classes/Case_Trigger_Alert_Count.

I have also noticed that in the 'Problems' tab, I have the message:
The sourcepath ".../force-app/main/default/classes/Case_Trigger_Alert_Count" is not a valid source file path.  SourcePathInvalid [1,1]

The filename of the file I have just created and attempting to deploy is 'Case_Trigger_Alert_Count"
What am I missing to be able to deploy to my Sandbox?

Hi,

I am trying to use Lightning out component out side salesforce, and I see the below error in the browser console.
" GET  https://rnrcommunities-developer-edition.na85.force.com/Test//c/lwcVfDemoApp.app?aura.format=JSON&aura.formatAdapter=LIGHTNING_OUT 404 (Not Found)"

Below is the code

<html>
<H1> Hello World </h1>
<div id="lightning"></div>
<script src="https://rnrcommunities-developer-edition.na85.force.com/Test/lightning/lightning.out.js"></script>
<script>
$Lightning.use("c:lwcVfDemoApp", function() {
$Lightning.createComponent("c:lwcVFDemo", {
objectName: "Contact"
},
"lightning",
function(cmp) {
console.log("LWC component was created");
// do some stuff
}
);
},
'https://rnrcommunities-developer-edition.na85.force.com/Test/'
);
</script>
</html>

NOTE: this is for allowing gues access.
Hello All,
I'm extremely new to lightning components and trying to replace some of our custom javascript buttons with lightning compatible options.  One button takes ownership of a lead.  I found a post that does something similar for cases and tried to modify it for my purpose: https://learnownlightning.blogspot.com/2018/01/change-owner-update-record-using.html

It seems to be doing the record update based on apex code, but it launches a quickaction screen with a cancel button that doens't go away.  I've seen it posted that you can use 
$A.get("e.force:closeQuickAction").fire();
It is not working for me.  I'm not sure if I'm not puting that code in the right place but I'm hoping someone can help me figure out a way to click the quick action button, have the lead change ownership, and that's it.

Here is my code so far:
Component:
<aura:component implements="force:lightningQuickAction,force:hasRecordId" controller="LightningComponent_MoveToMarketing" access="global" >
<aura:handler name="init" value="{!this}" action="{!c.doInit}"/>    
</aura:component>
Controller:
({
 doInit : function(component, event, helper) {
        var leadId = component.get("v.recordId");
        var action = component.get("c.changeOwnerMethod");
        action.setParams({
            leadId : leadId
        });
        action.setCallback(this, function(response) {
            if(response.getState() === "SUCCESS") {
                console.log("Lead Owner Changed To Current login User");
             var rec = response.getReturnValue();
             console.log(rec.OwnerId);
            }
        });
        $A.enqueueAction(action);
$A.get("e.force:closeQuickAction").fire();
        $A.get('e.force:refreshView').fire();
 }
})

Apex Class:
public class LightningComponent_MoveToMarketing {

    @AuraEnabled
    public static Lead changeOwnerMethod(Id leadId) {
        if(leadId != null) {
            Lead l = [SELECT OwnerId FROM Lead WHERE Id = :leadId];
         l.OwnerId = UserInfo.getUserId();
//update case Ownerid with loggedin userid.
            update l;
            return l;
        }
        return null;
    }

}

Any ideas?
 
My requirement is to create a contact , by clicking a button on the account detail page. Button click will open a new vf page with contact fields onto it.Account name field on new vf page must be auto popuated, where as rest of the contact fields can be typed in.
How do I achieve this?
Hello All,
I'm extremely new to lightning components and trying to replace some of our custom javascript buttons with lightning compatible options.  One button takes ownership of a lead.  I found a post that does something similar for cases and tried to modify it for my purpose: https://learnownlightning.blogspot.com/2018/01/change-owner-update-record-using.html

It seems to be doing the record update based on apex code, but it launches a quickaction screen with a cancel button that doens't go away.  I've seen it posted that you can use 
$A.get("e.force:closeQuickAction").fire();
It is not working for me.  I'm not sure if I'm not puting that code in the right place but I'm hoping someone can help me figure out a way to click the quick action button, have the lead change ownership, and that's it.

Here is my code so far:
Component:
<aura:component implements="force:lightningQuickAction,force:hasRecordId" controller="LightningComponent_MoveToMarketing" access="global" >
<aura:handler name="init" value="{!this}" action="{!c.doInit}"/>    
</aura:component>
Controller:
({
 doInit : function(component, event, helper) {
        var leadId = component.get("v.recordId");
        var action = component.get("c.changeOwnerMethod");
        action.setParams({
            leadId : leadId
        });
        action.setCallback(this, function(response) {
            if(response.getState() === "SUCCESS") {
                console.log("Lead Owner Changed To Current login User");
             var rec = response.getReturnValue();
             console.log(rec.OwnerId);
            }
        });
        $A.enqueueAction(action);
$A.get("e.force:closeQuickAction").fire();
        $A.get('e.force:refreshView').fire();
 }
})

Apex Class:
public class LightningComponent_MoveToMarketing {

    @AuraEnabled
    public static Lead changeOwnerMethod(Id leadId) {
        if(leadId != null) {
            Lead l = [SELECT OwnerId FROM Lead WHERE Id = :leadId];
         l.OwnerId = UserInfo.getUserId();
//update case Ownerid with loggedin userid.
            update l;
            return l;
        }
        return null;
    }

}

Any ideas?