4

While trying to create a custom business rule using Apex I got the error:

INVALID_ID_FIELD, SaveAsActivity is not allowed with whatId that is not supported as a task whatId.

...and found out that it was caused by the method setSaveAsActivity on my code, that was like:

msg.setSaveAsActivity(true); // "msg" is a SingleEmailMessage

What am I doing wrong here?

1 Answer 1

10

The error message can be a little confusing, but this error can be thrown if your main object (relatedTo in your template) doesn't have the "Allow Activities" option checked.

Checking this option will solve this issue.

This error message should be modified to something like "SaveSetAsActivity is not supported on objects that do not allow activities."

4
  • Probably? Or definitely? It makes sense that you wouldn't be able to save activities to an object which wouldn't allow them anyway.
    – Adrian Larson
    Commented Mar 15, 2017 at 16:05
  • I used "probably" because I really don't know if there are other circumstances that can result in the same error. Commented Mar 15, 2017 at 16:36
  • 2
    You might just clarify whether or not it solved your error.
    – Adrian Larson
    Commented Mar 15, 2017 at 16:38
  • Ok, done. Removed "probably". Commented Mar 15, 2017 at 17:34

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .