You need to sign in to do that
Don't have an account?
fuko9x
How to update hasAttachment = true in testclass trigger beforeInsert EmailMessage
I have trigger EmailMessage:
Code run normal but i can't create testclass.
EmailMessage.HasAttachment : Field is not writeable.
public void onBeforeInsert(List<EmailMessage> newListEmailMessage) { for (EmailMessage mess : newListEmailMessage) { if (!mess.HasAttachment) { newListEmailMessage.get(0).addError('NO ATTACHMENT'); return; } } }
Code run normal but i can't create testclass.
EmailMessage.HasAttachment : Field is not writeable.
Another thing as per the Email Message documentation (https://developer.salesforce.com/docs/atlas.en-us.api.meta/api/sforce_api_objects_emailmessage.htm), update() call is supported only the Status picklist value on the EmailMessage record is set to Draft. Hence, you may want to create the EmailMessage with Status as Draft and then update the HasAttachment field, though I am not sure if this will work.