You need to sign in to do that
Don't have an account?

Check if datetime field is empty
Hi folks,
I've been trying to look for a solution with no luck.
Simply, I'm trying to write an apex trigger to check whether a date/time field is empty while a status field is set to a specific value at the creation or the update of a record...
Any help much appreciated. Thanks
I've been trying to look for a solution with no luck.
Simply, I'm trying to write an apex trigger to check whether a date/time field is empty while a status field is set to a specific value at the creation or the update of a record...
Any help much appreciated. Thanks
you can directly check if Datetime field is empty using == null condition as shown in example below.
trigger SameEmailOnAllContacts on Account (after update) {
Set<Id> setAccountId = new Set<Id>();
for(Account acc:trigger.new) {
if(acc.Date_Time__c == null) {
setAccountId.add(acc.id);
}
}
system.debug('setAccountId:'+setAccountId);
}
Greetings to you!
I have practiced it in my org on custom object help.
I hope you find the above solution helpful. If it does, please mark as Best Answer to help others too.
Thanks and Regards,
Deepali Kulshrestha
You can update your code by below code according to your requirement in the apex class.
If You are applying null check in query.
I hope you find the above solution helpful. If it does, please mark as Best Answer to help others too.
Thanks,
Ajay Dubedi
Thanks, Guys for the replies. Please see below the script I'm using.
The error I'm getting in VS editor is the following: Method does not exist or incorrect signature: void isEmpty
Thanks again for your support!
trigger posIntallation on Installation__c (after insert, after update) {
List<Installation__c> apps = new List<Installation__c>();
apps = [select Installation_Date_Time__c from Installation__c where Status__c = 'Assigned'];
if (isEmpty(apps)) {
System.debug('Please choose the installation date and time for this application');
}
}
Greetings to you!
I have practiced it in my org on custom object help.
I hope you find the above solution helpful. If it does, please mark as Best Answer to help others too.
Thanks and Regards,
Deepali Kulshrestha