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) {
workspaceAPI.openSubtab({
parentTabId: enclosingTabId,
pageReference:
{
"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) {
console.log("error");
});
})
.catch(function(error) {
console.log(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.