0

I am trying to generate url to open visualforce page embedded in a LWC using iFrame but I am getting undefined while using Navigationmixin.GenerateUrl to get the url. Can anyone suggest the correct way here?

myLwc.html

<template>
    <iframe src={myFullUrl} style="width: 100%; height: 200px; border:0"></iframe>
</template>

myLwc.js

import { LightningElement, api, track, wire} from 'lwc';
import {OmniscriptBaseMixin} from 'vlocity_ins/omniscriptBaseMixin';
import { NavigationMixin } from 'lightning/navigation';
export default class MyLwc extends OmniscriptBaseMixin(NavigationMixin(LightningElement))  {
    @api
    get idvar () {
        return this._idvar;
    }
    set idvar(value) {
    this._idvar = value;
    }
    @track idvar;
    @track fullUrl
    @track interactionId;
    myFullUrl;
    urlWithParameters;
    // Omniscript LWC properties
    _idvar
    _fullUrl

    connectedCallback(){
        this[NavigationMixin.GenerateUrl]({
            type: "standard__webPage",
            attributes: {
                url: "/apex/InteractionActivity?Id=a266C000000GJ3SQAW"
            }
        }).then(url => {
            this.myFullUrl = url;
            console.log("FULL URL1 : " + this.myFullUrl);
        }).catch(error => {
            console.log(error);
        });
        console.log("FULL URL2 : " + this.myFullUrl);
    }
}

enter image description here

UPDATED SCREENSHOT:

enter image description here

1 Answer 1

1

The console log you have set is outside the promise. it is getting executing first before promise get resolved. You can put the console inside and you can see the value there.

    connectedCallback() {
        this[NavigationMixin.GenerateUrl]({
            type: "standard__webPage",
            attributes: {
                url: "/apex/InteractionActivity?Id="
            }
        }).then(url => {
            this.myFullUrl = url;
            console.log("FULL URL : " + this.myFullUrl);
        }).catch(error => {
            console.log(error);
        });
        console.log("FULL URL : " + this.myFullUrl);
    }

enter image description here

1
  • Hi @Sanket, thanks for correcting that silly mistake from my side but i am seeing a different issue after having the console log at correct place.
    – SunnyG
    Feb 1, 2021 at 14:48

You must log in to answer this question.

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