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
Jacob Elliott 8Jacob Elliott 8 

LWC Flow Screen Won't Proceed To Next Screen

Hey All, I have a LWC in a flow screen and when I click next, the screen refreshes but won't move to the next action in the flow. I'm not trying to use custom navigation. 
 

The purpose of the screen is to accept Mail/FileInfo collection of records and allow the user to decide to which team to send the records. It then outputs the collection "sendLegal" back to the flow.

HTML
 

<template>
    
    <template if:true={_mailList}>
        <template for:each={_mailList} for:item="mail">
            <lightning-layout-item key={mail.Id} size="3" class="slds-p-around_none">
                <div class="slds-box slds-p-around_none slds-m-top_x-small slds-m-bottom_medium slds-m-horizontal_none">
                    <lightning-layout>
                        <lightning-layout-item  key={mail.Id} padding="around-small">
                            <div class="custom-box slds-box slds-p-around_medium slds-text-align_center">
                                <lightning-button value={mail.Id} variant="Success" label="Legal" title="Download action with base variant" icon-name="utility:email" class="slds-m-left_x-small" onclick={handleLegal}></lightning-button>
                            </div>
                        </lightning-layout-item>
                        <lightning-layout-item padding="around-small">
                            <div class="custom-box slds-box slds-p-around_medium slds-text-align_center">
                                <lightning-button value={mail.Id} variant="Success" label="Doc" title="Download action with base variant" icon-name="utility:email" class="slds-m-left_x-small" onclick={handleDoc}></lightning-button>
                            </div>
                        </lightning-layout-item>
                        <lightning-layout-item padding="around-small">
                            <div class="custom-box slds-box slds-p-around_medium slds-text-align_center">
                                <lightning-button value={mail.Id} variant="Success" label="DT" title="Download action with base variant" icon-name="utility:email" class="slds-m-left_x-small" onclick={handleDT}></lightning-button>
                            </div>
                        </lightning-layout-item>
                        <lightning-layout-item padding="around-small">
                            <div class="custom-box slds-box slds-p-around_medium slds-text-align_center">
                              <p>{mail.Name}</p>
                            </div>
                        </lightning-layout-item>
                    </lightning-layout>
                </div>
            </lightning-layout-item>
        </template>
    </template>
</template>

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

export default class MedRecAlertsScreen extends LightningElement {
    @track _mailList = [];
    @api sendLegal = [];
    @track sendDoc = [];
    @track sendDT = [];

    @api
    get mailList(){
        let docUrl;
            return this._mailList = mailList.map(row => { 
                docUrl = `/${row.Id}`;
                return {...row , docUrl} 
            }) 
    }

    set mailList(val){
        let docUrl;
            this._mailList = val.map(row => { 
                docUrl = `/${row.Id}`;
                return {...row , docUrl} 
            }) 
    } 

    handleLegal(event){
        var tempLegal =[];
        console.log("clicked legal");
        if (event.target.iconName == "utility:email"){
            console.log("Icon Email");
            tempLegal.push(event.target.value);
            /* this.sendLegal.push(tempLegal[0]);
            console.log(this.sendLegal); */
            event.target.iconName = "utility:clear";
            event.target.variant = "Destructive";
            this.sendLegal.push(this._mailList.filter(mail => mail.Id == tempLegal[0]));
            for(let i = 0; i < this.sendLegal.length; i++){ console.log(this.sendLegal.length);}
            const attributeChangeEvent = new FlowAttributeChangeEvent('sendLegal', this.sendLegal);
            this.dispatchEvent(attributeChangeEvent); 
        } else if(event.target.iconName == "utility:clear"){
            console.log("Icon Clear");
            console.log("Icon Email");
            tempLegal.push(event.target.value);
            this.sendLegal.pop(tempLegal[0]);
            console.log(this.sendLegal);
            event.target.iconName = "utility:email";
            event.target.variant = "success";
            for(let i = 0; i < this.sendLegal.length; i++){ console.log(this.sendLegal.length);}
        }
    }


    @track mailcolumns = [{
            label: 'Legal Team',
            type:  'button',
            typeAttributes: 
            {
                iconName: 'utility:email',
                label: 'Legal', 
                name: 'legalTeam', 
                title: 'editTitle', 
                disabled: false, 
                value: 'test'
            },
            sortable: true,
    },
        {
        label: 'Documents Team',
        type:  'button',
        typeAttributes: 
            {
                iconName: 'utility:email',
                label: 'Doc', 
                name: 'documentsTeam', 
                title: 'editTitle', 
                disabled: false, 
                value: 'test'
            },
        sortable: true
    },
        {
        label: 'Disbursements Team',
        type:  'button',
        typeAttributes: 
            {
                iconName: 'utility:email',
                label: 'DT', 
                name: 'dtTeam', 
                title: 'editTitle', 
                disabled: false, 
                value: 'test'
            },
        sortable: true
    },
        {
        label: 'Document Name',
        fieldName: 'docUrl',
        type: 'url',
        typeAttributes: {label: { fieldName: 'Name' }, 
        target: '_blank'}, 
        sortable: true
    },
    ];
}

XML
<?xml version="1.0" encoding="UTF-8"?>
<LightningComponentBundle xmlns="http://soap.sforce.com/2006/04/metadata">
    <apiVersion>48.0</apiVersion>
    <isExposed>true</isExposed>
    <masterLabel>Mail Alert Screen</masterLabel>
    <description>For Mail Team To Choose Who To Alert</description>
    <targets>
        <target>lightning__FlowScreen</target>
    </targets>
    <targetConfigs>
        <targetConfig targets="lightning__FlowScreen">
            <property name="mailList" type="@salesforce/schema/litify_docs__File_Info__c[]"/>
            <property name="sendLegal" type="@salesforce/schema/litify_docs__File_Info__c[]" role="outputOnly"/>
           
        </targetConfig>
    </targetConfigs>
</LightningComponentBundle>

​​​​​​​FlowLWC screen​​​​​​​
ShirishaShirisha (Salesforce Developers) 
Hi Jacob,

Greetings!

Have you tried by debugging the flow alone to confirm,if the issue is with the flow or the lwc code.

Please use this doc (https://developer.salesforce.com/blogs/2019/02/debug-your-lightning-web-components.html) to debug your LWC component,if you are unable to figure out the root cause of the issue.

Kindly let me know if it helps you and close your query by marking it as best answer so that it can help others in the future.

Warm Regards,
Shirisha Pathuri