Overview
Use the triggered email API to work with the metadata of triggered emails and email fragments. The metadata is stored in the common/metadata/triggeredEmails.json file. You can update the file location and filename in the metadata and emailsManifest properties in ./.ewizard/settings.json. For more information, see Triggered emails.
To access the API, use the methods in the browser console in eWizard Editor.
TIP: The email or fragment must include the triggeredEmails.json file for the API to work.
Use this context to access the API and its methods:
window.ewizardjs.triggeredEmail
Use the following methods of the triggered email API to add, update, or get the triggeredEmails.json data:
• addEmail
addEmail
The addEmail method adds an email ID and other metadata fields such as name or url to the emails object in the triggeredEmails.json file.
window.ewizardjs.triggeredEmail.addEmail(id, data)
Parameters
Parameter  | Type  | Description  | 
  | String  | The email ID. This is a required parameter.  | 
  | Object  | The email metadata. Use the parameter to add any metadata fields to the specific email. This is an optional parameter.  | 
addFragment
The addFragment method adds an email fragment ID and other metadata fields such as name or url to the fragments object in the triggeredEmails.json file.
window.ewizardjs.triggeredEmail.addFragment(id, data)
Parameters
Parameter  | Type  | Description  | 
  | String  | The email fragment ID. This is a required parameter.  | 
  | Object  | The email fragment metadata. Use the parameter to add any metadata fields to the specific email fragment. This is an optional parameter.  | 
getEmailById
Use the getEmailById method to get the data from the emails field of the triggeredEmail.json file. Use the email ID to get the data.
window.ewizardjs.triggeredEmail.getEmailById(emailId)
Parameter
Parameter  | Type  | Description  | 
  | String  | The email ID. This is a required parameter.  | 
getEmailsJson
Use the getEmailsJson method to return all the emails and fragments from the triggeredEmails.json file of your e-Detailer project.
window.ewizardjs.triggeredEmail.getEmailsJson()
The getEmailsJson method has no parameters.
getFragmentById
Use the getFragmentById method to get the data from the fragments field of the triggeredEmails.json file. Use the email fragment ID to get the data.
window.ewizardjs.triggeredEmail.getFragmentById(fragmentId)
Parameter
Parameter  | Type  | Description  | 
  | String  | The fragment ID. This is a required parameter.  | 
removeEmail
Use the removeEmail method to remove an email and its metadata from the emails field of the triggeredEmails.json file. Enter the email ID to remove the metadata.
window.ewizardjs.triggeredEmail.removeEmail(id)
Parameter
Parameter  | Type  | Description  | 
  | String  | The email ID. This is a required parameter.  | 
removeFragment
Use the removeFragment method to remove an email fragment and its metadata from the fragments field of the triggeredEmails.json file. Enter the email fragment ID to remove the metadata.
window.ewizardjs.triggeredEmail.removeFragment(id)
Parameter
Parameter  | Type  | Description  | 
  | String  | The fragment ID. This is a required parameter.  | 
updateEmail
Use this method to update the email metadata in the triggeredEmails.json file. Enter the ID of the email to update the metadata in it.
window.ewizardjs.triggeredEmail.updateEmail(id, data)
Parameters
Parameter  | Type  | Description  | 
  | String  | The ID of the email you want to update. This is a required parameter.  | 
  | Object  | The metadata fields of the email you want to update. This is a required parameter.  | 
updateFragment
Use this method to update the email fragment metadata fields in the triggeredEmails.json file. Enter the ID of the email fragment to update the metadata in it.
window.ewizardjs.triggeredEmail.updateFragment(id, data)
Parameters
Parameter  | Type  | Description  | 
  | String  | The ID of the email fragment. This is a required parameter.  | 
  | Object  | The metadata fields of the email fragment. This is a required parameter.  | 
