import PARTICIPANT_FIELD from '@salesforce/schema/User.Contact.Active_Participant__c';
// LWC Code
@wire(getRecord, { recordId: USER_ID, fields: [PARTICIPANT_FIELD] })
wiredUser({ error, data }) {
if (data) {
this.participantRecordId = data.fields.Contact.value.fields[ACTIVE_PARTICIPANT_API.fieldApiName].value;
this.getParticipantStatusOutcome();
} else if (error && USER_CONTACT_ID !=undefined) {
showLog(error);
showErrorMessage( 'Error', error.body.message);
}
}
So in this block of code PARTICIPANT_FIELD will have User's contact field Active_Participant__c
but in some cases the contact is blank on User object due to which it gives me the error since data is not rendered here and it contains undefined.
Is it possible that for some users even though contact lookup on User is blank the error message should not be displayed? I cannot remove showErrorMessage( 'Error', error.body.message);
function here. I tried with various IF
conditions but still I get the error message, may be if data is undefined then error object will have value which is being shown in UI.
I need that error message shown from toast should not be shown even though Contact is blank on User record.