Global Action to Make Me owner of a record

Before Lightning Data Service, In order to save a record, we have to create the server method to process every request to save the information. By using Lightning Data Service we can reduce all unwanted server call and handle all the processing inside the controller.

In this scenario, I am explaining how to Own a Record in a button click.

Lightning gives us more flexibility when adding the action to the page layout.  So here is the common use case for all the object actions, which is Make Me the Owner. This can be used on any object (Case, Account, Contact, Lead, Custom Object).

we can change the Owner right inside client Controller within a lightning component.

Name this component as makeMeOwner

<aura:component implements="flexipage:availableForRecordHome,force:hasRecordId,force:lightningQuickAction" access="global" >
    <aura:attribute type="object" name="targetObject"/>
    <aura:attribute type="object" name="targetObjectError"/>
    <force:recordData aura:id="forceRecordCmp"

Click the controller from the lightning menu.

  doInit : function(cmp, event, helper) {
        var record = cmp.get("v.targetObject");
        record.OwnerId  = $A.get("$SObjectType.CurrentUser.Id") //current user Id
        helper.handleSaveRecord(cmp, event, helper);

Helper Class

  handleSaveRecord: function(component, event, helper) {
        component.find("forceRecordCmp").saveRecord($A.getCallback(function(saveResult) {
            if (saveResult.state === "SUCCESS" || saveResult.state === "DRAFT") {
                console.log("Save completed successfully.");
            } else if (saveResult.state === "INCOMPLETE") {
                console.log("User is offline, device doesn't support drafts.");
            } else if (saveResult.state === "ERROR") {
                console.log('Problem saving record, error: ' + 
            } else {
                console.log('Unknown problem, state: ' + saveResult.state + ', error: ' + JSON.stringify(saveResult.error));

Create a Global Actions from the setup and refer the above-created Lightning Component.

Next, drag this action from theSalesforce1 and Lightning Actions to the Salesforce1 and Lightning Experience Actions and save the page layout.