Subscription doesn't accept tokenised values for numeric fields

Created on 26 June 2023, over 1 year ago

Problem/Motivation

We're developing a form to subscribe to a mailing list that contains several Number fields on the Sendgrid end. However, upon configuring our Number inputs and using tokens to render the final value, Sendgrid doesn't actually subscribe the user, returning an error file containing a message upon the lines of the following:

error storing custom field name=CustomFieldName type=Number as value="300": expecting value to be sent as Number type

After some debugging it looks like the type of the value being compiled into the JSON body itself is a string instead of an integer or float. We reckon we can fix this by casting the value as it's added to the body prior to sending to Sendgrid.

Steps to reproduce

  1. Create a Sendgrid mailing list with one or more custom Number fields
  2. Create a Drupal webform to integrate with this
  3. Send a submission with an appropriate number value
  4. Check the job status using the ID that got returned

Proposed resolution

Cast all Number field values to an int or float prior to sending to Sendgrid.

Remaining tasks

Patch this module to cast field values as indicated.

User interface changes

None.

API changes

None.

Data model changes

None.

🐛 Bug report
Status

Needs review

Version

1.0

Component

Code

Created by

🇦🇺Australia geoffreyr

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @geoffreyr
  • @geoffreyr opened merge request.
  • Issue was unassigned.
  • Status changed to Needs review over 1 year ago
  • 🇦🇺Australia geoffreyr

    Have submitted a first pass merge request. Don't know what to do with Date field types yet, but we should be able to account for that as well.

Production build 0.71.5 2024