function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
sksfdc221sksfdc221 

How to display listview on record insert in lightning

I have a lightning component which inserts transfer record when clicked on Save button. Now, I have a process builder which creates 2 more records (rather clones this record) when the above record is saved. So a total of 3 records are getting inserted.

Below is my lightning component code which triggers save function

Lightning controller.js:
submitTransfer: function(component, event, helper) {
        helper.closeModelHeaderhelper(component);
            helper.submitTransferHelper(component, event, helper);
        helper.showSpinner(component);
    }
lightning helper.js:
submitTransferHelper: function(component, event, helper) {
        console.log("submitTransferHelper************************");
        var TransferRec = component.get("v.accountTransfer");       
        var action = component.get("c.insertAccountTransfer");
        action.setParams({
            accTrans: TransferRec,
        });
        action.setCallback(this, function(response) {
            var state = response.getState();
            if (state == "SUCCESS") {
                console.log("SUCCESS*****");
                helper.showToast(
                    component,
                    event,
                    helper,
                    "success",
                    "Success!",
                    "Transfer Request was saved successfully."
                );
                helper.redirectToSobject(response.getReturnValue());
            } else if (state == "ERROR") {
                let errorMess = response.getError();
                console.log(
                    "response.getError()*****" +
                        JSON.stringify(response.getError())
                );
                helper.showToast(
                    component,
                    event,
                    helper,
                    "error",
                    "Error!",
                    errorMess[0].message
                );
            }
        });
        $A.enqueueAction(action);
    }

Now, when the save button is clicked, although there are 3 records that are getting created, the detail page of the record which is saved from lightning component is getting opened by default and for other 2 records which are inserted by process builder, I need to go back and open them from list view.

is there any way i can display list view when save button is clicked so that I can display all three records in the view and user can open any of the three records of there choice.

Please suggest
brahmaji tammanabrahmaji tammana
You might need to return a wrapper after the DML statement (insert of a record from lightning component). This wrapper basically contains the inserted record and other two records created from process builder. 

You can display this wrapper in a modal once it is saved and received the response from server. I can think of only this solution at high level.