NavigationMixin.GenerateUrl can be used in the Salesforce Lightning Web Component to generate the URL. Then, we can use window.open() method to open new window using Quick Action.
HTML:
<template>
</template>
JavaScript:
import { LightningElement, api } from 'lwc';
import { NavigationMixin } from 'lightning/navigation';
export default class OpenAccountQuickAction extends NavigationMixin( LightningElement ) {
@api recordId;
@api invoke() {
console.log( "Inside Invoke Method" );
console.log( "Record Id is " + this.recordId );
this[ NavigationMixin.GenerateUrl ]( {
type: 'standard__recordPage',
attributes: {
recordId: this.recordId,
actionName: 'view',
},
} ).then( url => {
console.log( 'URL is ' + url );
let completeURL = window.location.origin + url;
let windowFeatures = "menubar=no,resizable=yes,scrollbars=yes";
windowFeatures = "width=" + screen.width;
windowFeatures += ",height=" + screen.height;
console.log( 'Complete URL is ' + completeURL );
window.open( completeURL, "_blank", windowFeatures );
} );
}
}
js-meta.xml:
<?xml version="1.0" encoding="UTF-8"?>
<LightningComponentBundle xmlns="http://soap.sforce.com/2006/04/metadata">
<apiVersion>52.0</apiVersion>
<isExposed>true</isExposed>
<targets>
<target>lightning__RecordAction</target>
<target>lightning__RecordPage</target>
</targets>
<targetConfigs>
<targetConfig targets="lightning__RecordAction">
<actionType>Action</actionType>
</targetConfig>
</targetConfigs>
</LightningComponentBundle>