You need to sign in to do that
Don't have an account?
MattyDHL
Method does not exist or incorrect signature: [Id].equals(String)
Hi,
I am still new to Apex, and learning more functions and expected this to work:
trigger DelCustPrevent on Account (before delete) { for (Account a : Trigger.old) { if (a.IF_SAP__c != NULL && a.RecordTypeId.equals('0122000000000lZAAQ')){ a.addError('You do not have permission to delete this record'); } { } } }
Can someone please help me, the error is on the RecordTypeId check, how can I make this Boolean check?
Regards
Matt
The equals method isn't available on the ID data type, you should use the == operator instead.
trigger DelCustPrevent on Account (before delete) { for (Account a : Trigger.old) { if (a.IF_SAP__c != NULL && a.RecordTypeId==('0122000000000lZAAQ')){ a.addError('You do not have permission to delete this record'); } { } } }
All Answers
The equals method isn't available on the ID data type, you should use the == operator instead.
trigger DelCustPrevent on Account (before delete) { for (Account a : Trigger.old) { if (a.IF_SAP__c != NULL && a.RecordTypeId==('0122000000000lZAAQ')){ a.addError('You do not have permission to delete this record'); } { } } }
Thanks for the reply.
Exactly, I tried the == with quotes but not brackets around the quotes, i tried like this:
Thanks
If you have the time, can you help me to understand why I need to use the brackets there?
Again, much appriciated.
Matt
'
Not sure about that, I tried it successfully both ways. The only reason I used the parens was because I copied your sample code and replaced the .equals with the ==.
Did you get an error when you did it that way?
Hi,
Yup, something like "AND operator can only be applied to boolean"
hmmm, strange, cause i tried that at first, then i searched and found information about using the .equals
Matt
Matt