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')
     }
  });
  • lwc comp is not available for action overrides yet, are you using aura comp for record selection? – salesforce-sas Aug 14 at 8:35
1

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.

  • 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 ? – raidu sai krishna teja Aug 19 at 12:26
  • Is there any way to prepopulate values in some of the fields while opening the new popup ? – raidu sai krishna teja Aug 29 at 7:32
  • I dont think, have to check. However, in force:createRecord, you cn prepopulate – salesforce-sas Aug 29 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 – raidu sai krishna teja Sep 9 at 11:10
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

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.