I am launching a Subtab using the Lightning Workspace API, and using an Aura pageReference object to specify that I want to create a new Task.

I want to pre-populate the WhatId on the Task when the new standard__object tab opens.

I set the WhatId in the state I want to pass into the pageReference object:

var workspaceAPI = component.find("workspace");
var recordId = component.get("v.recordId") // confirmed this is my intended WhatId recordId
workspaceAPI.getEnclosingTabId().then(function(enclosingTabId) {
            parentTabId: enclosingTabId,
                "type": "standard__objectPage",
                "attributes": {
                    "objectApiName": "Task",
                    "actionName": "new"
                "state": {
                    "WhatId": recordId
        }).then(function(subtabId) {
            console.log("The new subtab ID is:" + subtabId);
        }).catch(function(error) {
.catch(function(error) {

But it doesn't appear to be passing the input as a query parameter - and when the new record lightning component opens in the subtab the Related: input field is blank.


I figured out the appropriate answer is to use the force:createRecord event:

var createRecordEvent = $A.get("e.force:createRecord");
    "entityApiName": "Task",
    "defaultFieldValues": {
         // "WhatId": 

Also, it appears that when fired from within a subtab this event will open a new subtab, I am not sure if it works the other way around.

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.