I have below Javascript function in lwc
apexJobInfoData;
@track isBatch;
getData({ error, data }) {
if (error) {
// TODO: handle error
} else if (data) {
this.jobId = getFieldValue(data, JOB_ID);
getAllApexJobInfo({ ApexJobId: this.jobId})
.then(result => {
this.apexJobInfoData = result.JobInfo.length===0?null:result.JobInfo;
this.error = undefined;
if(apexJobInfoData!=null){
apexJobInfoData.forEach((element) => {
if(element.JobType === 'BatchApex'){
this.isBatch = true;
}
})
}
alert('Error Calling Alert Here'); // This line does not execute
})
.catch(error => {
this.message = undefined;
this.error = error;
});
}
I am not sure what's happening but after there is something wrong with below piece of code. After this nothing gets executed.
if(apexJobInfoData!=null){
console.log('Enters here');
apexJobInfoData.forEach((element) => {
console.log('Doesn't enter here');
})
}
What am I missing here.
apexJobInfoData
after logging it viaconsole.log
. Maybe it is not anArray
but aString
that looks likeArray
. Also, can you add console logs to know exactly at what line does it stop.this.isBatch = !!apexJobInfoData.find(element=>element.JobType === 'BatchApex')
instead.apexJobInfoData
is not anArray
but aString
like'[a,b,c,d]'