1

I've created a lightning component in which a Case record will get create automatically(using force:recordData) from account and contact. Once the record gets created at the backend I need to redirect the page to newly created case and at the same time need to open edit pop up for same record.ths is what i need Actually I'm using this component in the lightning service console so facing 2 problems: 1. for the first time, on selection of case record type from account or contact a Case record is getting created but edit window is not opening. And if I select the record type again from different account or contact record edit window will popup. 2. As I'm using service console if I select the record type from account or contact case will get create and redirect to new tab in console. But trying to reset the component or value or want to refresh the particular account . or contact tab in the console so that I can select another record type and works the same way. enter image description here enter image description here

10
  • Can you post your code? If you are using service console, then use workspace api to navigate to records. Oct 19, 2019 at 6:14
  • @NagendraSingh I've tried the workspace api also and its redirecting the new tab but edit popup of same record is not working in that case. Oct 19, 2019 at 7:36
  • try combining the two like this : salesforce.stackexchange.com/a/265683/45062 Open it via workspace api and use Navigationapi to trigger the record mode. Oct 19, 2019 at 12:08
  • only tab is opening but edit popup is not coming. Oct 19, 2019 at 14:38
  • Did you add navigator api? What is the error? Oct 19, 2019 at 15:16

1 Answer 1

1

Use navigation api in combination with your workspace api.

Like this:

handleRecordTypeSelection: function (component, event, helper) {
    var recordTypeName = event.getSource().get("v.value");
    component.set("v.caseField.RecordTypeId", recordTypeName);
    component.find("caseRecordCreator").saveRecord(function (saveResult) {
        if (saveResult.state === "SUCCESS" || saveResult.state === "DRAFT") {
            var workspaceAPI = component.find("workspace");
            workspaceAPI.openTab({
                recordId: saveResult.recordId, 
                focus: true
            }).then(function() {
                navigatorApi.navigate({
                    type: 'standard__recordPage',
                    attributes: {
                        recordId: saveResult.recordId,
                        actionName: 'edit'
                    }
                })
            })
        }
    })
}

Or Like this ;

workspaceAPI.openTab({
    recordId:  v,
    focus: true
 }).then(function() {
    var editRecordEvent = $A.get("e.force:editRecord");
    editRecordEvent.setParams({
        "recordId": v
    });
    editRecordEvent.fire();
 })
1

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .