In my current scenario, I am facing a challenge with checking both conditions simultaneously. If an attachment exists in the request but the attachment field does not exist in the form, it should display a message in the modal. Similarly, if body text exists in the request but the rich text field does not exist in the form, it should show an error.
However, when an attachment exists in the request and the attachment field also exists, the code moves to the else if statement. But if the rich text field is missing in the form, it doesn't show an error because the nested if statement is not executed. I am unsure of how to address both conditions at the same time.
if (this.selectedForm) {
let attachmentField = this.selectedForm.formFields.filter(formField => {
return formField.fieldAttributeType == 'attachment'
})
let descriptionField = this.selectedForm.formFields.filter(formField =>{
return formField.fieldAttributeType == 'rich_text'
})
debugger
if (this.request.attachments.length > 0 && attachmentField.length == 0) {
debugger
this.missingFields.push("Attachment field does't exist in custom form");
if (this.request.bodyText.length > 0 && descriptionField.length == 0) {
this.missingFields.push("and Rich_text field does't exist in custom form");
}
this.$refs.ticketCreationConfirmation.open();
} else if (this.missingFields.length == 0){
this.addRequest(this.request);
}
}