+ Start a Discussion
Haseeb Ahmad 9Haseeb Ahmad 9 

Help on Lightning action button

Hello everyone. 

I need your help/guidance for looking at the lightning action button as I am not able to figure out why the lightning action button not working when I click on options and I get this message but nothing happened.
User-added imageHere is the code in .HTML file inside lwc
 
<template>
    <!-- <div class="slds-text-heading_small">If your profile is either Solutions engineer, Professional Services or System Administrator
            you will have the option to create a Word or PDF SOW. If not the SOW will be saved as PDF.</div> -->
            <lightning-button variant="brand" label="Create PDF SOW" title="PDF SOW" onclick={createPdf} class="slds-var-m-left_x-small"></lightning-button>
    <template if:true={showSecondButton}>
        <lightning-button variant="brand" label="Create Doc SOW" title="PDF SOW" onclick={createDoc} class="slds-var-m-left_x-small"></lightning-button>
    </template>
    <br>
    <template if:true={error}>
            The following error has occured. {error}
            Please report error to salesops.
    </template> 
    <template if:true={results}>
           Results :{results}. please click the close button at the bottom of this dialog.
    </template>
    </template>

Here is the code I have in .JS file inside lwc
 
import { LightningElement, api, track } from 'lwc';
import getCurrentUserProfileName from '@salesforce/apex/LightningUtils.getCurrentUserProfileName';
import generateSOW from '@salesforce/apex/ZuoraDocumentGenerator.generateSOW';
export default class QuickActionDocGen extends LightningElement {
    @api recordId;
    @track showSecondButton = false;
    @api profileName;
    @api error;
    @api results;
    connectedCallback() {
       
        getCurrentUserProfileName()
        
            .then(result => {
                this.profileName = result;
                console.log('User Profile : ', result);
                // All the logic that we will use to show one or two buttons
                const profilesWithSecondButton = ['Solution Engineer','Professional Services','System Administrator'];
                this.showSecondButton = profilesWithSecondButton.includes(result);

            })
            .catch(error => {
                console.warn('Error Getting User Profile', error);
            })

    }
    createPdf () {
        this.results = generateSOW(this.recordId, 'PDF'); // calling apex method with record id and pdf
        //eval("$A.get('e.force:closeQuickAction').fire();");
        //this.dispatchEvent(closeclickedevt); 
        window.close();
    }
    createDoc () {
        this.results = generateSOW(this.recordId, 'DOC'); // calling apex method with record id and Doc
        window.close();
    }
}

Can Anyone please help me with this? thank you.