I am trying to reproduce the button we have in the SF Classic in to Lightning. The button (Pass to Customer Service) assigns the cases to the Owner (Customer Services whose id is(eg: 00GU0000001eW6XYZA') on click of a button in the Classic. I have been reading about the quick action and take ownership button on Lightning but they makes the users Select/assign the owner to the record selected. But what I am trying to do is onclick of the button it should directly assign the record to the ownerID specified. How can I do it.

var caseObj = new sforce.SObject("Case");
caseObj.Id = '{!Case.Id}';
caseObj.OwnerId = '00GU0000001eW6XYZA';
var result2 = sforce.connection.update([caseObj]);
if (result2[0].success=='true') {

I tried implementing this as Lightning Component in Quick Action like below


<aura:component implements="flexipage:availableForRecordHome,force:hasRecordId,force:lightningQuickAction" controller="ChangeOwnerClass" access="global" >
    <aura:handler name="init" value="{!this}" action="{!c.doInit}"/>


 doInit : function(component, event, helper) {
        var caseId = component.get("v.recordId");
        var action = component.get("c.changeOwnerMethod");
            caseId : caseId
        action.setCallback(this, function(response) {
            if(response.getState() === "SUCCESS") {
                console.log("Case Owner Changed To Domestic Customer Service");

And the class

public class ChangeOwnerClass {
    public static Case changeOwnerMethod(Id caseId) {
        if(caseId != null) {
           Case c = [SELECT OwnerId FROM Case WHERE Id = :caseId];
         c.OwnerId =  '00GU0000001eW6XYZA';
            update c;
            return c;
        return null;

I added the component as a Quick Action added it in to the Layout. The issue is this Quick Action doesnt appear as a button, instead it shows in the Feed


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.