You need to sign in to do that
Don't have an account?
Seth Payne
execution of BeforeInsert caused by: System.NullPointerException: Argument cannot be null.
The error above is the used when i have this code:
trigger HD5HashGeneratorContact1 on Contact (before insert, before update) {
for (contact c : Trigger.new){
if (c.HD5Hash__c == null) {
c.HD5Hash__c = EncodingUtil.convertToHex(Crypto.generateDigest('MD5', Blob.valueOf(c.id)));
break;
}
}
When I change the code to after insert this is the error i get:
execution of AfterInsert caused by: System.FinalException: Record is read-only:
trigger HD5HashGeneratorContact1 on Contact (after insert, before update) {
for (contact c : Trigger.new){
if (c.HD5Hash__c == null) {
c.HD5Hash__c = EncodingUtil.convertToHex(Crypto.generateDigest('MD5', Blob.valueOf(c.id)));
break;
}
}
}
}
What do i need to do to be able to generate a MD5 Hash out of the contact ID?
Thanks,
Seth
trigger HD5HashGeneratorContact1 on Contact (before insert, before update) {
for (contact c : Trigger.new){
if (c.HD5Hash__c == null) {
c.HD5Hash__c = EncodingUtil.convertToHex(Crypto.generateDigest('MD5', Blob.valueOf(c.id)));
break;
}
}
When I change the code to after insert this is the error i get:
execution of AfterInsert caused by: System.FinalException: Record is read-only:
trigger HD5HashGeneratorContact1 on Contact (after insert, before update) {
for (contact c : Trigger.new){
if (c.HD5Hash__c == null) {
c.HD5Hash__c = EncodingUtil.convertToHex(Crypto.generateDigest('MD5', Blob.valueOf(c.id)));
break;
}
}
}
}
What do i need to do to be able to generate a MD5 Hash out of the contact ID?
Thanks,
Seth
Instead you can on an after insert trigger,
call another apex class that has asynchronous method that updates your contact. Something like
Build new instance of the contact list and update them.
You can write the Apex class
You can also create a new instance of all the contacts you want to update in trigger and update them within trigger. Something like
All Answers
Instead you can on an after insert trigger,
call another apex class that has asynchronous method that updates your contact. Something like
Build new instance of the contact list and update them.
You can write the Apex class
You can also create a new instance of all the contacts you want to update in trigger and update them within trigger. Something like