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:
Component:
<aura:component implements="force:lightningQuickAction,lightning:availableForFlowActions">
<aura:attribute name="URLpassing" type="String"/>
</aura:component>
JS cONTROLLER:
({
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
redirect.fire();
}
})
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: HTML:
<template>
<div>
<lightning-button class="aButton" label="URLCreator" onclick={UrlCreator}></lightning-button>
</div>
</template>
JS:
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
sforce.one.navigateToUrl(generatedUrl);
});
}
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