0% found this document useful (0 votes)
3 views

inboundCallDetails js

The document is a Lightning Web Component (LWC) script for managing inbound call details in a Salesforce application. It includes functionalities for fetching details, handling user inputs for call and issue types, and managing dynamic fields based on user selections. The component also integrates with Visualforce pages for displaying maps and company locations, and provides user feedback through toast messages.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views

inboundCallDetails js

The document is a Lightning Web Component (LWC) script for managing inbound call details in a Salesforce application. It includes functionalities for fetching details, handling user inputs for call and issue types, and managing dynamic fields based on user selections. The component also integrates with Visualforce pages for displaying maps and company locations, and provides user feedback through toast messages.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 16

import { LightningElement, api, track } from 'lwc';

import getDetails from '@salesforce/apex/SCADAAlarmController.getDetails';


import getCompanyLocations from
'@salesforce/apex/CreateMonitoringActivityController.getCompanyLocations';
import getIssueTypeOptions from
'@salesforce/apex/SCADAAlarmController.getIssueTypeOptions';
import getCallTypeOptions from
'@salesforce/apex/SCADAAlarmController.getCallTypeOptions';
import getICM_Metadata from
'@salesforce/apex/SCADAAlarmController.getICM_Metadata';
import saveRecord from '@salesforce/apex/SCADAAlarmController.createInboundCall';
import { NavigationMixin } from 'lightning/navigation';
import { ShowToastEvent } from 'lightning/platformShowToastEvent';
const columns = [
{ label: 'Name', fieldName: 'Name', type: 'text' },
{ label: 'Address__c', fieldName: 'Address__c', type: 'text' },

];
export default class InboundCallDetails extends NavigationMixin(LightningElement) {

@api enableinboundmodel = false;


@track vfPageUrl = '/apex/googleMap';
//vfRoot = "https://natresponse--nrcdev1--c.sandbox.vf.force.com/";
@track vfRoot = "";
@track mapMarkers = [];
@track zoomLevel = 15;
@track showMap = true;
coordinates = {
latitude: undefined,
longitude: undefined,
formatted_address: '',
street: '',
country: '',
region: '',
postal_code: '',
locality: ''
};
assetLoc;
columns = columns;
isLoading = false;
@track issueTypeDisabled = true;
@track callTypeDisabled = true;
showRecordDetails = false;
@track customer;
callType = '';
issueType = '';
notes;
searchCriteria;
issueTypeOptions = [];
callTypeOptions = [];
dispatchToOptions = [];
outboundDynamicFields = [];
inboundDynamicFields = [];
customerdata = [];
hasBothContacts = false;
contactfields = [];
hasBothName = false;
namefields = [];
locationInfo = {
fieldValue: '',
showField: false,
disableField: false,
isRequiredField: false
};

//Issue Field Value Store


@track fName = '';
@track lName = '';
@track contactOne = '';
@track contactTwo = '';
hasValue = false;

get statusOptions() {
return [
{ label: '--None--', value: '' },
{ label: 'Completed', value: 'Completed' },
{ label: 'NRC Dispatcher', value: 'NRC Dispatcher' },
{ label: 'Ignore Alarm', value: 'Ignore Alarm' },
];
}

connectedCallback() {
this.initDetails();
window.addEventListener("message", (message) => {
console.log(message.origin);
console.log('LWC - Received message:', message.data);
this.coordinates = JSON.parse(JSON.stringify(message.data));
console.log('this.coordinates>>>117', this.coordinates);
});
}

initDetails() {

getDetails()
.then(result => {
this.vfRoot = result;
})

handleAccountChange(event) {
if (event.target.dataset.field == 'Name') {
this.isLoading = true;
this.customer = event.detail.selectedRecord;
this.callTypeDisabled = true;
this.issueTypeDisabled = true;
this.callType = '';
this.issueType = '';
this.callTypeOptions = [];
this.issueTypeOptions = [];
this.outboundDynamicFields = [];
this.inboundDynamicFields = [];
this.contactfields = [];
this.namefields = [];
this.coordinates = {
latitude: undefined,
longitude: undefined,
formatted_address: '',
street: '',
country: '',
region: '',
postal_code: '',
locality: ''
};
this.locationInfo = {
fieldValue: '',
showField: false,
disableField: false,
isRequiredField: false
};

if (this.customer != '' && this.customer != undefined) {


getCallTypeOptions({ accountId: this.customer })
.then(result => {
if (result != undefined && result.length > 1) {
this.isLoading = false;
this.callTypeOptions = result;
this.callTypeDisabled = false;
}
else {
this.isLoading = false;
this.callTypeDisabled = true;
this.issueTypeDisabled = true;
this.callType = '';
this.issueType = '';
this.outboundDynamicFields = [];
this.inboundDynamicFields = [];
this.contactfields = [];
this.namefields = [];
this.coordinates = {
latitude: undefined,
longitude: undefined,
formatted_address: '',
street: '',
country: '',
region: '',
postal_code: '',
locality: ''
};
this.locationInfo = {
fieldValue: '',
showField: false,
disableField: false,
isRequiredField: false
};
const event = new ShowToastEvent({ title: '', message:
'No call type values found.', variant: 'info', });
this.dispatchEvent(event);
}
})
} else {
this.isLoading = false;
this.callTypeDisabled = true;
this.issueTypeDisabled = true;
this.callType = '';
this.issueType = '';
this.outboundDynamicFields = [];
this.inboundDynamicFields = [];
this.contactfields = [];
this.namefields = [];
this.coordinates = {
latitude: undefined,
longitude: undefined,
formatted_address: '',
street: '',
country: '',
region: '',
postal_code: '',
locality: ''
};
this.locationInfo = {
fieldValue: '',
showField: false,
disableField: false,
isRequiredField: false
};
}
}
}

handleCallTypeChange(event) {
this.callType = event.target.value;
this.issueTypeDisabled = true;
this.issueType = '';
this.issueTypeOptions = [];
this.outboundDynamicFields = [];
this.inboundDynamicFields = [];
this.contactfields = [];
this.namefields = [];
this.coordinates = {
latitude: undefined,
longitude: undefined,
formatted_address: '',
street: '',
country: '',
region: '',
postal_code: '',
locality: ''
};
this.locationInfo = {
fieldValue: '',
showField: false,
disableField: false,
isRequiredField: false
};
if (this.customer != '' && this.customer != undefined && this.callType !=
'' && this.callType != undefined) {
this.isLoading = true;
getIssueTypeOptions({ accountId: this.customer, callType: this.callType
})
.then(result => {
if (result != undefined && result.length > 1) {
this.isLoading = false;
this.issueTypeOptions = result;
this.issueTypeDisabled = false;
} else {
this.isLoading = false;
this.issueTypeDisabled = true;
this.issueType = '';
this.outboundDynamicFields = [];
this.inboundDynamicFields = [];
this.contactfields = [];
this.namefields = [];
this.coordinates = {
latitude: undefined,
longitude: undefined,
formatted_address: '',
street: '',
country: '',
region: '',
postal_code: '',
locality: ''
};
this.locationInfo = {
fieldValue: '',
showField: false,
disableField: false,
isRequiredField: false
};
const event = new ShowToastEvent({ title: '', message: 'No
issue type values found.', variant: 'info', });
this.dispatchEvent(event);
}
})
} else {
this.isLoading = false;
this.issueTypeDisabled = true;
this.issueType = '';
this.outboundDynamicFields = [];
this.inboundDynamicFields = [];
this.contactfields = [];
this.namefields = [];
this.coordinates = {
latitude: undefined,
longitude: undefined,
formatted_address: '',
street: '',
country: '',
region: '',
postal_code: '',
locality: ''
};
this.locationInfo = {
fieldValue: '',
showField: false,
disableField: false,
isRequiredField: false
};
}
}

handleIssueTypeChange(event) {
console.log('hasRun>>>');
this.isLoading = true;
this.issueType = event.target.value;
//get dynamic fields
if (this.customer != '' && this.customer != undefined && this.issueType !=
'' && this.issueType != undefined && this.callType != undefined && this.callType !=
'') {
getICM_Metadata({ accountId: this.customer, issueType: this.issueType,
callType: this.callType })
.then(result => {
console.log('resultIssueType>>>', result);
if (result != null && result != undefined) {
let nameFieldOUT = result.namefields;

for( i = 0; i < nameFieldOUT.length; i++){


if(nameFieldOUT[i].fieldAPIName == 'First_Name__c'){
nameFieldOUT[i].fieldValue = this.fName;
} else if(nameFieldOUT[i].fieldAPIName ==
'Last_Name__c'){
nameFieldOUT[i].fieldValue = this.lName;
break;
}
}

if(this.hasValue){
let contactfields = result.contactfields;
for (i = 0; i < contactfields.length; i++ ) {
if (contactfields[i].fieldAPIName == 'Contact_1__c') {

contactfields[i].fieldValue = this.contactOne;
} else if (contactfields[i].fieldAPIName ==
'Contact_2__c') {
contactfields[i].fieldValue = this.contactTwo;
break;
}
}
}

if (result.outboundDynamicFields) {
this.outboundDynamicFields =
result.outboundDynamicFields;
} else {
this.outboundDynamicFields = [];
}
if (result.inboundDynamicFields) {

this.inboundDynamicFields =
result.inboundDynamicFields;

if (result.inboundDynamicFields != undefined &&


result.inboundDynamicFields != null) {
this.inboundDynamicFields =
result.inboundDynamicFields;
console.log('outputfields',
this.inboundDynamicFields);
for (var i = 0; i <
this.inboundDynamicFields.length; i++) {

if (this.inboundDynamicFields[i].isText &&
this.inboundDynamicFields[i].fieldAPIName == 'Description') {
if (this.inboundDynamicFields[i].fieldValue
!= undefined || this.inboundDynamicFields[i].fieldValue != null ||
this.inboundDynamicFields[i].fieldValue != '') {

this.inboundDynamicFields[i].isDescription = true;
this.inboundDynamicFields[i].isText =
false;
}

}
}
console.log('afterexitfields',
this.inboundDynamicFields);
}

} else {
this.inboundDynamicFields = [];
}
if (result.contactfields) {
this.contactfields = result.contactfields;
if (this.contactfields.length == 2) {
this.hasBothContacts = true;
} else {
this.hasBothContacts = false;
}
} else {
this.contactfields = [];
}
if (result.namefields) {
this.namefields = result.namefields;
if (this.namefields.length == 2) {
this.hasBothName = true;
} else {
this.hasBothName = false;
}
} else {
this.namefields = [];
}

if (result.locationInfo) {
this.locationInfo = result.locationInfo;
this.coordinates.formatted_address =
this.locationInfo.fieldValue;
if (this.locationInfo.showField &&
this.coordinates.formatted_address) {
setTimeout(() => {

this.populateLocationAdd(this.coordinates.formatted_address);
}, 3000);
}
if (this.locationInfo.disableField) {
setTimeout(() => {
if (this.template.querySelector("iframe")) {
var vfWindow =
this.template.querySelector("iframe").contentWindow;
if (vfWindow) {
vfWindow.postMessage(true,
this.vfRoot);
}
}
}, 3000);
}
if (!this.locationInfo.showField) {
this.showMap = false;
}
} else {
this.coordinates = {
latitude: undefined,
longitude: undefined,
formatted_address: '',
street: '',
country: '',
region: '',
postal_code: '',
locality: ''
};
this.locationInfo = {
fieldValue: '',
showField: false,
disableField: false,
isRequiredField: false
};
}
this.isLoading = false;
} else {
this.outboundDynamicFields = [];
this.inboundDynamicFields = [];
this.contactfields = [];
this.namefields = [];
this.coordinates = {
latitude: undefined,
longitude: undefined,
formatted_address: '',
street: '',
country: '',
region: '',
postal_code: '',
locality: ''
};
this.locationInfo = {
fieldValue: '',
showField: false,
disableField: false,
isRequiredField: false
};
this.isLoading = false;
}
})
} else {
this.isLoading = false;
this.outboundDynamicFields = [];
this.inboundDynamicFields = [];
this.contactfields = [];
this.namefields = [];
this.coordinates = {
latitude: undefined,
longitude: undefined,
formatted_address: '',
street: '',
country: '',
region: '',
postal_code: '',
locality: ''
};
this.locationInfo = {
fieldValue: '',
showField: false,
disableField: false,
isRequiredField: false
};
}

handleNotesChange(event) {
this.notes = event.target.value;
}

loadCompanyLocations(event) {
this.isLoading = true;
console.log('Marker', this.coordinates);
console.log('Event Target Dataset Value', event.target.dataset.value ===
'ShowMap');
console.log('Event Target Dataset Value POI', event.target.dataset.value
=== 'POI');

if (event.target.dataset.value === 'ShowMap') {


if (this.coordinates != undefined && this.coordinates.latitude !=
undefined && this.coordinates.latitude != '' &&
this.coordinates.longitude != undefined &&
this.coordinates.longitude != '') {
const coordinatesObject = this.coordinates;
console.log('coordinatesObject', coordinatesObject);
this.mapMarkers = [
{
location: {
Latitude: this.coordinates.latitude,
Longitude: this.coordinates.longitude,
},
},
];

console.log('coordinates.latitude', this.coordinates.latitude);
console.log('coordinates.longitude', this.coordinates.longitude);

console.log('Map Markers', this.mapMarkers);


} else {
const event = new ShowToastEvent({ title: 'Error', message: 'Please
select the location', variant: 'warning', });
this.dispatchEvent(event);
}
}

if (event.target.dataset.value === 'POI') {


if (this.customer == undefined || this.customer == '') {
const event = new ShowToastEvent({ title: 'Error', message: 'Please
select the customer', variant: 'warning', });
this.dispatchEvent(event);
} else {
getCompanyLocations({ recordId1: this.customer })
.then(result => {
console.log('Result from getCompanyLocations:', result);

if (result && result.length > 0) {


this.customerdata = result; // Extract the first record
from the array
console.log('this.customerdata', this.customerdata);
this.showRecordDetails = true;
} else {
console.log('No records found.');
const event = new ShowToastEvent({ title: '', message:
'No records found.', variant: 'info', });
this.dispatchEvent(event);
}
})
.catch(error => {
this.error = error;
console.error('Error fetching company locations:', error);
});
}
}
this.isLoading = false;
}

showSCADAModel(event) {
this.enableinboundmodel = true;
this.dispatchEvent(new CustomEvent('showinboundmodel', {
detail: {
message: this.enableinboundmodel
}
}));
}

hideSCADAModel(event) {
this.enableinboundmodel = false;
this.dispatchEvent(new CustomEvent('showinboundmodel', {
detail: {
message: this.enableinboundmodel
}
}));
}

closeModal(event) {
this.showRecordDetails = false;
}

handleAssetLocationSelection(event) {
this.showRecordDetails = false;

if (this.assetLoc.formatted_address) {
const address = Array.isArray(this.assetLoc.formatted_address) ?
this.assetLoc.formatted_address : [this.assetLoc.formatted_address];
console.log('Sending address from LWC:', address);

var vfWindow = this.template.querySelector("iframe").contentWindow;


vfWindow.postMessage(address, this.vfRoot);
console.log('Posted message to VF:', address);

this.coordinates.formatted_address = this.assetLoc.formatted_address;
this.coordinates.latitude = this.assetLoc.latitude;
this.coordinates.longitude = this.assetLoc.longitude;
this.coordinates.country = '';
this.coordinates.postal_code = '';
this.coordinates.region = '';
this.coordinates.street = '';
this.coordinates.locality = '';
}
}

handleRowSelection = event => {


var selectedRows = event.detail.selectedRows;
console.log('selectedRows:', selectedRows);
if (selectedRows && selectedRows.length > 1) {
var el = this.template.querySelector('lightning-datatable');
el.selectedRows = [selectedRows[selectedRows.length - 1]];
return;
} else {
this.assetLoc = { formatted_address: '', latitude: undefined,
longitude: undefined };
}

// Extract and use the values from the selected rows directly
selectedRows.forEach(row => {
this.assetLoc.formatted_address = row.Address__c;
this.assetLoc.latitude = row.Location__Latitude__s;
this.assetLoc.longitude = row.Location__Longitude__s;
console.log('Address__c:', this.coordinates.formatted_address);
});

};

handleInputChange(event) {
var fieldName = event.target.dataset.name;
for (var i = 0; i < this.outboundDynamicFields.length; i++) {
if (this.outboundDynamicFields[i].fieldAPIName == fieldName) {
if (this.outboundDynamicFields[i].isCheckbox) {
this.outboundDynamicFields[i].fieldValue =
event.target.checked;
} else if (this.outboundDynamicFields[i].isLookup) {
this.outboundDynamicFields[i].fieldValue =
event.detail.recordId;
} else if (this.outboundDynamicFields[i].isMultiPicklist) {
this.outboundDynamicFields[i].multiPicklistValue =
event.target.value;
} else {
this.outboundDynamicFields[i].fieldValue = event.target.value;
}
}
}
}

handleInboundValuesChange(event) {
var fieldName = event.target.dataset.name;
for (var i = 0; i < this.inboundDynamicFields.length; i++) {
if (this.inboundDynamicFields[i].fieldAPIName == fieldName) {
if (this.inboundDynamicFields[i].isCheckbox) {
this.inboundDynamicFields[i].fieldValue = event.target.checked;
} else if (this.inboundDynamicFields[i].isLookup) {
this.inboundDynamicFields[i].fieldValue =
event.detail.recordId;
} else if (this.inboundDynamicFields[i].isMultiPicklist) {
this.inboundDynamicFields[i].multiPicklistValue =
event.target.value;
} else {
this.inboundDynamicFields[i].fieldValue = event.target.value;
}
}
}
}

handleContactValuesChange(event) {
var fieldName = event.target.dataset.name;
console.log('####', event.target.value);

if (fieldName == 'Contact_1__c') {
this.contactOne = event.target.value;
} else if (fieldName == 'Contact_2__c') {
this.contactTwo = event.target.value;
}

for (var i = 0; i < this.contactfields.length; i++) {


if (this.contactfields[i].fieldAPIName == fieldName) {
if (this.contactfields[i].isMultiPicklist) {
this.contactfields[i].multiPicklistValue = event.target.value;
} else {
this.contactfields[i].fieldValue = event.target.value;
}
}
}
this.hasValue = true;
}
handleNameValuesChange(event) {
console.log('************', event.target.value);
var fieldName = event.target.dataset.name;
var fieldIndex = event.target.dataset.index;

if (fieldName == 'First_Name__c') {
this.fName = event.target.value;
} else if (fieldName == 'Last_Name__c') {
this.lName = event.target.value;
}

console.log('fieldIndex>', fieldIndex);
for (var i = 0; i < this.namefields.length; i++) {
if (this.namefields[i].isMultiPicklist) {
this.namefields[i].multiPicklistValue = event.target.value;
} else {
this.namefields[fieldIndex].fieldValue = event.target.value;
//this.namefields[fieldName].fieldValue = event.target.value;
}
}
}

handleSearchChange(event) {
this.searchCriteria = event.target.value;
console.log('searchCriteria', this.searchCriteria);

let accId1 = this.customer;


getCompanyLocations({ recordId1: accId1 })
.then(result => {
console.log('Result from getCompanyLocations>>>>', result);
if (result && result.length > 0) {
this.customerdata = result.filter(record =>

record.Name.toLowerCase().includes(this.searchCriteria.toLowerCase()) ||

record.Address__c.toLowerCase().includes(this.searchCriteria.toLowerCase())
);
console.log('Filtered Data:', this.customerdata);
this.showRecordDetails = true;
} else {
console.log('No records found.');
}
})
.catch(error => {
this.error = error;
console.error('Error fetching company locations:', error);
});
}

handleSave(event) {
this.isLoading = true;
let inputFields = this.template.querySelectorAll('lightning-input');
inputFields.forEach(inputField => {
if (!inputField.checkValidity()) {
inputField.reportValidity();
}
});
let inputPicklistFields = this.template.querySelectorAll('lightning-
combobox');
inputPicklistFields.forEach(inputPicklistFields => {
if (!inputPicklistFields.checkValidity()) {
inputPicklistFields.reportValidity();
}
});
if (this.customer != undefined && this.customer != null && this.customer !=
'' &&
this.issueType != undefined && this.issueType != null && this.issueType
!= '' &&
this.callType != undefined && this.callType != null && this.callType !=
'' &&
(this.locationInfo.showField == false ||
this.locationInfo.isRequiredField == false || (this.locationInfo.showField &&
this.locationInfo.isRequiredField && this.coordinates != undefined &&
this.coordinates != null &&
(this.coordinates.formatted_address != undefined &&
this.coordinates.formatted_address != null && this.coordinates.formatted_address !=
'') ||
(this.coordinates.latitude != undefined &&
this.coordinates.longitude != undefined && this.coordinates.latitude != '' &&
this.coordinates.longitude != '') &&
this.coordinates.latitude != null && this.coordinates.longitude != null))) {

var validRequiredInputs = true;


if (this.outboundDynamicFields) {
for (var i = 0; i < this.outboundDynamicFields.length; i++) {
if (this.outboundDynamicFields[i].showField &&
this.outboundDynamicFields[i].isRequiredField &&
(this.outboundDynamicFields[i].fieldValue == null ||
this.outboundDynamicFields[i].fieldValue == '' ||
this.outboundDynamicFields[i].fieldValue == undefined)) {
validRequiredInputs = false;
}

}
}
if (this.inboundDynamicFields) {
for (var i = 0; i < this.inboundDynamicFields.length; i++) {
if (this.inboundDynamicFields[i].showField &&
this.inboundDynamicFields[i].isRequiredField &&
(this.inboundDynamicFields[i].fieldValue == null ||
this.inboundDynamicFields[i].fieldValue == '' ||
this.inboundDynamicFields[i].fieldValue == undefined)) {
validRequiredInputs = false;
}
}
}
if (this.contactfields) {
for (var i = 0; i < this.contactfields.length; i++) {
if (this.contactfields[i].showField &&
this.contactfields[i].isRequiredField && (this.contactfields[i].fieldValue == null
|| this.contactfields[i].fieldValue == '' || this.contactfields[i].fieldValue ==
undefined)) {
validRequiredInputs = false;
}

}
}

if (this.namefields) {
for (var i = 0; i < this.namefields.length; i++) {
if (this.namefields[i].showField &&
this.namefields[i].isRequiredField && (this.namefields[i].fieldValue == null ||
this.namefields[i].fieldValue == '' || this.namefields[i].fieldValue == undefined))
{
validRequiredInputs = false;
}

}
}

if (validRequiredInputs == true) {
var inboundDetails = {
accountId: this.customer,
issueType: this.issueType,
callType: this.callType,
callerLastName: this.callerLastName,
callerFirstName: this.callerFirstName,
notes: this.notes
}
var dynamicFields = [];
if (this.outboundDynamicFields) {
for (var i = 0; i < this.outboundDynamicFields.length; i++) {
dynamicFields.push(this.outboundDynamicFields[i]);
}
}
if (this.inboundDynamicFields) {
for (var i = 0; i < this.inboundDynamicFields.length; i++) {
dynamicFields.push(this.inboundDynamicFields[i]);
}
}
if (this.contactfields) {
for (var i = 0; i < this.contactfields.length; i++) {
dynamicFields.push(this.contactfields[i]);
}
}

if (this.namefields) {
for (var i = 0; i < this.namefields.length; i++) {
dynamicFields.push(this.namefields[i]);
}
}

if (dynamicFields) {
for (var i = 0; i < dynamicFields.length; i++) {
if (dynamicFields[i].isMultiPicklist &&
dynamicFields[i].multiPicklistValue) {
dynamicFields[i].fieldValue =
Array.isArray(dynamicFields[i].multiPicklistValue) ?
dynamicFields[i].multiPicklistValue.join(';') :
dynamicFields[i].multiPicklistValue;
}
}
}

saveRecord({ inboundDetails: JSON.stringify(inboundDetails),


coordinates: JSON.stringify(this.coordinates), caseFields:
JSON.stringify(dynamicFields) })
.then(result => {
if (result.success == true) {
this.isLoading = false;
const event = new ShowToastEvent({ title: 'Success',
message: 'Case created successfully', variant: 'success', });
this.dispatchEvent(event);
this.enableinboundmodel = false;
this.dispatchEvent(new CustomEvent('showinboundmodel',
{
detail: {
message: this.enableinboundmodel
}
}));

if (result.recordId) {
this[NavigationMixin.Navigate]({
type: 'standard__recordPage',
attributes: {
recordId: result.recordId,
actionName: 'view',
},
});
}

} else {
this.isLoading = false;
const event = new ShowToastEvent({ title: 'Error',
message: result.msg, variant: 'error', });
this.dispatchEvent(event);
}
})
} else {
this.isLoading = false;
const event = new ShowToastEvent({ title: 'Error', message: 'Please
enter the required fields', variant: 'warning', });
this.dispatchEvent(event);
}
} else {
this.isLoading = false;
const event = new ShowToastEvent({ title: 'Error', message: 'Please
enter the required fields', variant: 'warning', });
this.dispatchEvent(event);
}
}

populateLocationAdd(adress) {
const address = Array.isArray(adress) ? adress : [adress];
console.log('Sending address from LWC:', address);

if (this.template.querySelector("iframe")) {
var vfWindow = this.template.querySelector("iframe").contentWindow;
if (vfWindow) {
vfWindow.postMessage(address, this.vfRoot);
}

}
console.log('Posted message to VF:', address);
}

You might also like