Execute a Queueable class when Salesforce community user access Lightning URL
1 |
APEX Class invoking Queueable Class |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
public with sharing class GenerateQuoteCommunity { @AuraEnabled public static String runGenerateQuoteQueueable() { GenerateQuoteQueueable gqf = new GenerateQuoteQueueable( '0Q011000000OyGX', false, true, false, true, '0DB0Z0000007k4t', 'Excel' ); Id jobId = System.enqueueJob(gqf); return 'executed'; } public GenerateQuoteCommunity() { } } |
1 |
LWC - JS File |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
import { LightningElement, wire,track } from 'lwc'; import getJobId from '@salesforce/apex/GenerateQuoteCommunity.runGenerateQuoteQueueable'; export default class GenerateQuoteTest extends LightningElement { @track jobId; handleLoad() { getJobId().then(result => { this.jobId = result; }) .catch(error => { this.error = error; }) } } |
1 |
LWC - HTML File |
<template>
<lightning-card title=”Execute GenerateQuoteQueueable” icon-name=”custom:custom63″>
<p class=”slds-m-bottom_small”>
<lightning-button label=”Execute Queue” onclick={handleLoad}></lightning-button>
</p>
<div class=”slds-m-around_medium”>
<template if:true={responseReceived}> {jobId} </template>
</div> </lightning-card></template>