0

I have a requirement to override 'New' button for record type selection CASE object, on recordType selection for one of the record type(1 out of 4) i need to open custom LWC component. for 3 remaining record types i need to open standard lightning popups.

I created LWC component for opening record type selection. from that popup i am opening new standard record creation popup. There while clicking on the cancel it is just closing the popup and staying on the record type selection lwc. But i need to redirect to case list view.

Custom LWC for record type selectoin Case object enter image description here

enter image description here

I am opening this standard record creation popup by using below code with returl but while clicking on the cancel button, it is not going back to case list view.

    this[NavigationMixin.Navigate]({
        "type": "standard__webPage",
       "attributes": {
          "url": str.concat(this.recordTypeId, '&retURL=%2F500%2Fo')
     }
  });
1
  • lwc comp is not available for action overrides yet, are you using aura comp for record selection? Commented Aug 14, 2019 at 8:35

2 Answers 2

2

You should not really use standard__webPage.

Instead you can use standard__objectPage like below:

this[NavigationMixin.Navigate]({
        type: "standard__objectPage",
        attributes: {
            objectApiName: "Account",
            actionName: "new"
        },
        state: {
            nooverride: 1,
            useRecordTypeCheck: 1,
            navigationLocation: 'LIST_VIEW',
            backgroundContext: '/lightning/o/Account/list?filterName=00B280000047uEuEAI',
            recordTypeId: '0120K000000TO5KQAW'
        }
    });

You can get the filterName from using SOQL SELECT Id, Name, SobjectType FROM ListView WHERE SobjectType='Account'.

This will open the new record form (standard form) over list view. So, when its cancelled, directly mentioned list view is shown.

9
  • Thanks @salesforce-sas it is working as expected. Is there any way to prepopulate values in some of the fields while opening the new popup ? Commented Aug 19, 2019 at 12:26
  • Is there any way to prepopulate values in some of the fields while opening the new popup ? Commented Aug 29, 2019 at 7:32
  • I dont think, have to check. However, in force:createRecord, you cn prepopulate Commented Aug 29, 2019 at 7:35
  • Hi salesforce-sas, I have added the above code and it is working fine in normal lightning application. but when comes to console app.the record creation popup opening in separate tab. Do you know anything about this Commented Sep 9, 2019 at 11:10
  • @salesforce-sas, I'm having a similar requirement, where I just want to close the modal on click of save button. Can you please share the attribute names that I need to set or the document links from where you got know about the different state properties. My question link - salesforce.stackexchange.com/questions/284484/… Commented Nov 12, 2019 at 6:26
1

You will not have any control over the popup you are using in Lightning. What i can suggest is use lightning-record-form component which enables you to quickly create forms to add, view, or update a record. You can create your own custom modal popup and use lightning-record-form in the body. You will have the control on events like :-

  1. Onload
  2. Onsuccess
  3. Oncancel
  4. Onerror

Note:- It accepts the recordType id and respect field-level security and sharing for you, so users see only the data that they have access to.

Read more about them:- lightning-record-form

And a sample custom modal popup example in LWC recipes is here:- Modal

You must log in to answer this question.

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