0

If we override the new button with custom component, then how we can get the record id of the record while clicking the New button from the related list?

I have used workspaceAPI to get the recodeId.

getCaseId : function(component) {
    var workspaceAPI = component.find("workspace");
    workspaceAPI.getFocusedTabInfo().then(function(response) {
        var strVal = response.pageReference.state.ws;
        if(response.recordId){
             component.set('v.caseId', response.recordId);
        }else if(strVal){
            strVal = strVal.replace("/lightning/r/Case/", '');
            strVal = strVal.replace("/view", '');
            component.set('v.caseId', strVal);
        }
        //console.log('CASE ID:::' + component.get('v.caseId'));
    })
    .catch(function(error) {
        console.log(error);
    });
}

This is also working. But I am searching alternative solution.

1 Answers1

0

Last time I checked, accessing the parent Id from related list's button wasn't possible.

Here is the idea: Get parentId when overriding standard actions with a lightning components

There were 2 workarounds:

  1. Wrap the aura component in a VF page and use it for override.

  2. Parse the URL and get the Id.

Raul
  • 18,794
  • 5
  • 39
  • 66