diff --git a/flow_screen_components/quickLookup/force-app/main/default/aura/QuickLightningLookup/QuickLightningLookup.cmp b/flow_screen_components/quickLookup/force-app/main/default/aura/QuickLightningLookup/QuickLightningLookup.cmp index 82d848bf6..c9762d209 100644 --- a/flow_screen_components/quickLookup/force-app/main/default/aura/QuickLightningLookup/QuickLightningLookup.cmp +++ b/flow_screen_components/quickLookup/force-app/main/default/aura/QuickLightningLookup/QuickLightningLookup.cmp @@ -113,6 +113,10 @@ IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + + + +
diff --git a/flow_screen_components/quickLookup/force-app/main/default/aura/QuickLightningLookup/QuickLightningLookupController.js b/flow_screen_components/quickLookup/force-app/main/default/aura/QuickLightningLookup/QuickLightningLookupController.js index df416f906..48a6816c9 100644 --- a/flow_screen_components/quickLookup/force-app/main/default/aura/QuickLightningLookup/QuickLightningLookupController.js +++ b/flow_screen_components/quickLookup/force-app/main/default/aura/QuickLightningLookup/QuickLightningLookupController.js @@ -33,7 +33,13 @@ IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. helper.hideDropDown(component); } }, false)); - + }, + handleInvokeLookup : function(component, event, helper) { + const { searchString } = event.getParam("arguments"); + if(searchString) { + document.getElementById(component.getGlobalId() + "_myinput").value = searchString; + helper.hlpPerformLookup(component); + } }, performLookup : function(component, event, helper) { helper.hlpPerformLookup(component); diff --git a/flow_screen_components/quickLookup/force-app/main/default/aura/quickLookup/quickLookup.cmp b/flow_screen_components/quickLookup/force-app/main/default/aura/quickLookup/quickLookup.cmp index 7280ecd55..68f74a574 100644 --- a/flow_screen_components/quickLookup/force-app/main/default/aura/quickLookup/quickLookup.cmp +++ b/flow_screen_components/quickLookup/force-app/main/default/aura/quickLookup/quickLookup.cmp @@ -23,6 +23,8 @@ + + @@ -34,14 +36,22 @@ {!v.label} - - + + + + + + + +
diff --git a/flow_screen_components/quickLookup/force-app/main/default/aura/quickLookup/quickLookup.design b/flow_screen_components/quickLookup/force-app/main/default/aura/quickLookup/quickLookup.design index 3af1e756c..e34376d13 100644 --- a/flow_screen_components/quickLookup/force-app/main/default/aura/quickLookup/quickLookup.design +++ b/flow_screen_components/quickLookup/force-app/main/default/aura/quickLookup/quickLookup.design @@ -17,5 +17,6 @@ + diff --git a/flow_screen_components/quickLookup/force-app/main/default/aura/quickLookup/quickLookupController.js b/flow_screen_components/quickLookup/force-app/main/default/aura/quickLookup/quickLookupController.js index 829fdafd4..38141e047 100644 --- a/flow_screen_components/quickLookup/force-app/main/default/aura/quickLookup/quickLookupController.js +++ b/flow_screen_components/quickLookup/force-app/main/default/aura/quickLookup/quickLookupController.js @@ -1,5 +1,22 @@ ({ doInit: function (component, event, helper) { helper.hlpCheckValidity(component, event); + }, + handleScanSuccess: function (component, event, helper) { + const componentA = component.find('QuickLightningLookup'); + const scannedBarcode = event.getParam('value'); + componentA.invokeLookup(scannedBarcode); + }, + handleScanError: function (component, event, helper) { + const errorMessage = event.getParam('detail'); + var toast = $A.get('e.force:showToast'); + if (toast) { + //fire the toast event in Salesforce app and Lightning Experience + toast.setParams({ + title: 'Error!', + message: errorMessage + }); + toast.fire(); + } } }); \ No newline at end of file diff --git a/flow_screen_components/quickLookup/force-app/main/default/lwc/fsc_barcodeScanner/fsc_barcodeScanner.html b/flow_screen_components/quickLookup/force-app/main/default/lwc/fsc_barcodeScanner/fsc_barcodeScanner.html new file mode 100644 index 000000000..a2eb7a692 --- /dev/null +++ b/flow_screen_components/quickLookup/force-app/main/default/lwc/fsc_barcodeScanner/fsc_barcodeScanner.html @@ -0,0 +1,7 @@ + \ No newline at end of file diff --git a/flow_screen_components/quickLookup/force-app/main/default/lwc/fsc_barcodeScanner/fsc_barcodeScanner.js b/flow_screen_components/quickLookup/force-app/main/default/lwc/fsc_barcodeScanner/fsc_barcodeScanner.js new file mode 100644 index 000000000..cb1c1ffc9 --- /dev/null +++ b/flow_screen_components/quickLookup/force-app/main/default/lwc/fsc_barcodeScanner/fsc_barcodeScanner.js @@ -0,0 +1,85 @@ +import { LightningElement, api, track } from 'lwc'; +import { ShowToastEvent } from 'lightning/platformShowToastEvent'; +import { getBarcodeScanner } from 'lightning/mobileCapabilities'; +import { FlowAttributeChangeEvent } from 'lightning/flowSupport'; + +export default class fsc_barcodeScanner extends LightningElement { + barcodeScanner; + scannerDisabled = false; + @track barcodeScannedValue; + @api + get barcodeScanned() { + return this.barcodeScannedValue; + } + set barcodeScanned(value) { + this.barcodeScannedValue = value; + } + + connectedCallback() { + this.barcodeScanner = getBarcodeScanner(); + if (this.barcodeScanner == null || !this.barcodeScanner.isAvailable()) { + this.scannerDisabled = true; + } + } + + handleBeginScanClick() { + const scanningOptions = { + scannerSize: 'XLARGE', + cameraFacing: 'BACK', + showSuccessCheckMark: true, + vibrateOnSuccess: true, + manualConfirmation: true, + previewBarcodeData: true, + enableBulkScan: false, + enableMultiScan: false + }; + + this.barcodeScannedValue = ''; + if (this.barcodeScanner != null && this.barcodeScanner.isAvailable()) { + this.barcodeScanner + .scan(scanningOptions) + .then((result) => { + this.handleScannedBarcodes(result); + }) + .catch((error) => { + this.handleError(error); + }) + .finally(() => { + this.barcodeScanner.dismiss(); + }); + } else { + this.showToast('Barcode Scanner Is Not Available', 'Try again from the Salesforce app on a mobile device.', 'error', 'sticky'); + } + } + + handleScannedBarcodes(barcode) { + console.log(JSON.stringify(barcode)); + if (barcode && barcode.length > 0) { + const value = barcode[0]?.value; //decodeURIComponent + this.barcodeScannedValue = value; + this.dispatchEvent(new CustomEvent('scansuccess', { detail: { value } })); + + this.dispatchEvent(new CustomEvent('notifychange', { detail: { value: value } })); + + const attributeChangeEvent = new FlowAttributeChangeEvent('barcodeScanned', value); + this.dispatchEvent(attributeChangeEvent); + } + } + + showToast(title, message, variant, mode) { + this.dispatchEvent( + new ShowToastEvent({ + title: title, + message: message, + variant: variant, + mode: mode + }) + ); + } + + handleError(error) { + this.dispatchEvent(new CustomEvent('scanerror', { detail: error })); + + this.showToast('Barcode Scanner Error', JSON.stringify(error), 'error', 'sticky'); + } +} \ No newline at end of file diff --git a/flow_screen_components/quickLookup/force-app/main/default/lwc/fsc_barcodeScanner/fsc_barcodeScanner.js-meta.xml b/flow_screen_components/quickLookup/force-app/main/default/lwc/fsc_barcodeScanner/fsc_barcodeScanner.js-meta.xml new file mode 100644 index 000000000..22909cdb7 --- /dev/null +++ b/flow_screen_components/quickLookup/force-app/main/default/lwc/fsc_barcodeScanner/fsc_barcodeScanner.js-meta.xml @@ -0,0 +1,14 @@ + + + 62.0 + true + BarCode Scanner Action + + lightning__FlowScreen + + + + + + + \ No newline at end of file