I am trying to call the class in my trigger that validates that only one of the custom fields must be populated and that custom fields cannot be empty. Below is my class and trigger, that shows of the error: Must specify the metadata file Please help me to resolve the issue!
public with sharing class FieldnotEmptycontrl {
public static Property__c field {get; set;}
public FieldnotEmptycontrl(){
field = new Property__c();
}
public static void fieldNotEmpty(List<Property__c> prop){
if(field.Business__c == null || field.Contact__c == null){
field.Business__c.addError('You must enter a value!');
field.Contact__c.addError('You must enter a value!');
if(field.Business__c != null && field.Contact__c != null){
field.Business__c.addError('Cannot use two fields at the same time. Please choose only one field Business or Contact');
field.Contact__c.addError('Cannot use two fields at the same time. Please choose only one field Business or Contact');
}
}
}
}
TRIGGER:
trigger fieldNotEmpty on Property__c (before insert, before update, after insert) {
Property__c[] prop = Trigger.new;
if (Trigger.isBefore || Trigger.isInsert) {
FieldnotEmptycontrl.fieldNotEmpty(prop);
}
}
if
and attempting to operate on a static property (which isnull
) rather than the passed list, but error quoted sounds like a deployment problem.