You need to sign in to do that
Don't have an account?
Travis Wright
APEX Code help - Check if Number field is Blank or Null
I have a trigger and have to change the logic a little check if a number field is Null. I have done some research and everything is telling me to use the IsNull Fuction and it keep getting the error below and Can't figure it out. I have the section of code that is giving me the issue.
Error Error: Compile Error: Method does not exist or incorrect signature: IsNull(Decimal) at line 3 column 4
trigger AssignTerritoryType on Account (Before insert, Before update) {
For (Account a :trigger.new){
if(IsNull(a.Fortune_1000_Rank__c) && (a.NumberOfEmployees >= 10000) && (a.Industry != 'Education')==True ||
IsNull(a.Fortune_1000_Rank__c) && (a.AnnualRevenue >= 800000000) && (a.Industry != 'Education')==True ||
a.Industry == 'Energy' ||
a.Industry == 'Pharma/BioTech' ||
a.Industry == 'Fed - Gov' ||
a.Fortune_1000_Rank__c <=650 )
{
a.Major__c=true;
a.Mid__c=False;
a.Inside__c=False;
a.Inside_small__c=False;
}
Error Error: Compile Error: Method does not exist or incorrect signature: IsNull(Decimal) at line 3 column 4
trigger AssignTerritoryType on Account (Before insert, Before update) {
For (Account a :trigger.new){
if(IsNull(a.Fortune_1000_Rank__c) && (a.NumberOfEmployees >= 10000) && (a.Industry != 'Education')==True ||
IsNull(a.Fortune_1000_Rank__c) && (a.AnnualRevenue >= 800000000) && (a.Industry != 'Education')==True ||
a.Industry == 'Energy' ||
a.Industry == 'Pharma/BioTech' ||
a.Industry == 'Fed - Gov' ||
a.Fortune_1000_Rank__c <=650 )
{
a.Major__c=true;
a.Mid__c=False;
a.Inside__c=False;
a.Inside_small__c=False;
}
All Answers
{ // Do something if the decimal variable is not null and not blank }
In this condition, the first part checks if the decimal variable is not null using the != null comparison operator. The second part checks if the decimal variable is not blank using the String.valueOf() method to convert the decimal value to a string, and then trimming any whitespace characters using the trim() method, before comparing it to an empty string using the != operator.