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
Afzaal HassanAfzaal Hassan 

How to convert Aura into a LWC JS code

I have a LWC code where if you click the button it generates a URL and then opens it. I have another aura component that is launched from a flow and it does the exact same thing as the LWC but this actually works and the LWC is not working. I was wondering if anyone could help me on how to rewrite the aura controller code as a LWC JS code? Here is the working aura code:
<aura:component implements="force:lightningQuickAction,lightning:availableForFlowActions">
<aura:attribute name="URLpassing" type="String"/> </aura:component>
invoke : function(component, event, helper)
var URL = component.get("v.URLpassing");
var redirect = $A.get("e.force:navigateToURL");
// Pass the record ID to the event
redirect.setParams({ "url": URL, });
// Open the record; } })
The url is passed from a flow to this aura component
I want to replicate the controller code into my LWC JS so it behaves the same way. This is what my Lwc is doing:
<lightning-button class="aButton" label="URLCreator" onclick={UrlCreator}>
</div> </template>
export default class URLCreate extends NavigationMixin(LightningElement) {
@api recordId;
@api accId;
@track PageUrl;
URLCreator(event) {
this.PageUrl = '/apex/AVFpage_HTML';
this.PageUrl += "&accountId="+ this.accId; this[NavigationMixin.GenerateUrl]
({ type: 'standard__webPage',
attributes: { url: this.PageUrl } }).then(generatedUrl => {
//this set of code I dont think is working. I need to replicate this like my aura controller code; });
If anymore can help, that would create. Again, since my aura is working, I would like to mimic the functionality/code into my LWC but I dont know how to write that aura functionality as LWC Thank you
AbhishekAbhishek (Salesforce Developers)

The above blog has some examples which might help you.

For reference check this too (

Let me know if it helps you and close your query by marking it as solved so that it can help others in the future.