Search code examples
javascriptdynamics-crmdynamics-crm-2015

Determine whether an email is about to be send without customizing the vanilla send button


I need to determine on client side whether an email record is about to be send. In addition, I rather not customizing the vanilla send button. Is there a way to do it?

My scenario: I need to display a message to the user on send, but not on reply or on forward. Currently, the message is displayed onSave like so:

var SAVE_MODES = { SEND: 7 };
function onSave (eContext) {
   if (eContext.getEventArgs().getSaveMode() == SAVE_MODES.SEND) {
      displayMyMessage();
   }
}

However, the condition evaluates to true not only on send, but also on reply, and on forward, which is undesired.


Solution

  • Got it, simply check against the value of statecode. If it's value is 0 (i.e, open), display the message (else, the email is on a state wherein the "reply" and the "forward" buttons are displayed).