Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

parseTokens error with complex data when using send-grid-protocol with cbmailservices #34

Merged
merged 2 commits into from Sep 13, 2023

Conversation

robertz
Copy link
Contributor

@robertz robertz commented Jun 15, 2023

Description

SendGrid allows you to use handlebars to render data when using dynamic templates (email type "template"). If you try to send complex (nested data) it will cause an error when parsing tokens:

As an example, here are a set of bodyTokens for a SendGrid dynamic template:

{
  "contact_name": "Smith, John Alfred",
  "account_name": "Awesome Company.",
  "parts": [
    {
      "end_use": "Mil/Aero",
      "quantity": 5,
      "sku": "1013",
      "end_user": "Awesome Company",
      "item_type": "EVB",
      "status_type": "Start"
    }
  ],
  "subject": "A new request has been created for Awesome Company",
  "priority_type": "High"
}

Issues

If you attempt to pass complex data you will receive an error that "complex object types cannot be converted to simple values." Since tokens are handled at send grid, skip processing if the email type is "template" and just send the values across as-is. In this case the body value will just be a templateID, there is no need for token replacement.

Type of change

  • [ X ] Bug Fix
  • [ X ] Improvement

Testing

CommandBox> testbox run --noVerbose
Executing tests http://localhost:50745/test-harness/tests/runner.cfm?&recurse=true&reporter=json&verbose=false please wait...

╔═════════════════════════════════════════════════════════════════════╗
║ Passed ║ Failed ║ Errored ║ Skipped ║ Bundles ║ Suites ║ Specs ║
╠═════════════════════════════════════════════════════════════════════╣
║ 50 ║ 0 ║ 0 ║ 0 ║ 11 ║ 12 ║ 50 ║
╚═════════════════════════════════════════════════════════════════════╝

TestBox v5.0.0
CFML Engine Lucee v5.3.10.120
Duration 767ms
Labels ---

@lmajano lmajano merged commit 06a9f57 into coldbox-modules:development Sep 13, 2023
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants