You need to sign in to do that
Don't have an account?
Anand TripathiSBI
how to change the owner of record from available list using aura component?
How to change owner of record(using List of active users in org) in aura component? I am trying to change the owner of the lead to available users in my org using aura component.
I want to display change owner button on my aura page and when i click thne list of users will poped up. And Now I can assign the lead to new owner. My code is given below.Please correct me.
*ChangeOwner.cmp*
<aura:component implements="flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,force:hasRecordId" controller="ChangeOwner" 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:refreshView').fire();
$A.get("e.force:closeQuickAction").fire();
}
})
//Apex Class//
public class ChangeOwner {
@AuraEnabled
public static Lead changeOwnerMethod(Id leadId) {
if(leadId != null) {
Lead l = [SELECT OwnerId FROM Lead WHERE Id = :leadId];
l.OwnerId = UserInfo.getUserId();
update l;
return l;
}
return null;
}
}
I want to display change owner button on my aura page and when i click thne list of users will poped up. And Now I can assign the lead to new owner. My code is given below.Please correct me.
*ChangeOwner.cmp*
<aura:component implements="flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,force:hasRecordId" controller="ChangeOwner" 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:refreshView').fire();
$A.get("e.force:closeQuickAction").fire();
}
})
//Apex Class//
public class ChangeOwner {
@AuraEnabled
public static Lead changeOwnerMethod(Id leadId) {
if(leadId != null) {
Lead l = [SELECT OwnerId FROM Lead WHERE Id = :leadId];
l.OwnerId = UserInfo.getUserId();
update l;
return l;
}
return null;
}
}