0

I am trying to create a lwc button which changes a variable when clicked and it works but the problem is that the variable does not change while the screen is opened and it just changes whenever i press finish .

For example here I am setting a visibility of a component to show only if the variable is test

enter image description here

and when the button is clicked the variable should be test but when i try to click the button the condition does not succeed but in the debugging it shows that the variable is set so does anyone know why is this happening . The image below shows that the value was set but it did not reflect on the screen component

This shows that the variable was set

This is the js code

import { LightningElement, api, track } from 'lwc';
import { FlowAttributeChangeEvent,
FlowNavigationNextEvent,
}           from 'lightning/flowSupport';

export default class GenericFlowButton extends LightningElement {
    @api inputTest;
    @api outputTest;
    @api label;

    renderedCallback() {
        const button = this.template.querySelector('lightning-button');
        console.log('Button: '+button);

        button.label=this.label;
    }


       handleClick(event) {
        const attributeChangeEvent = new FlowAttributeChangeEvent('outputTest','test');
        this.dispatchEvent(attributeChangeEvent); 


    }

}

1 Answer 1

0

I am facing same issue. You cannot get changes on static screen even if variable value is changed. You need to change the screen, then it will reflected.

In my case I was taking input name and on button click (input and button both was on LWC component) name should display on same screen flow screen (Display Text). but after clicking button my event was working successful but it is not changing the value on runtime.

What you can do is, just create an Assignment for assigning same variable value into same variable (it is just distraction). and point that assignment to your previous screen again eg. screen001 -> assignment -> screen001 then it will work.

Hope it will help in your scenario.

You must log in to answer this question.

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