Skip to content

fix: infer phone country code from E.164 numbers in workflow Create Record#19063

Closed
jnMetaCode wants to merge 1 commit intotwentyhq:mainfrom
jnMetaCode:fix/workflow-phone-country-code-17182
Closed

fix: infer phone country code from E.164 numbers in workflow Create Record#19063
jnMetaCode wants to merge 1 commit intotwentyhq:mainfrom
jnMetaCode:fix/workflow-phone-country-code-17182

Conversation

@jnMetaCode
Copy link
Copy Markdown

Summary

  • Fixes a bug where Workflow "Create Record" action drops the calling code (+91) and country code when a phone field is populated with an E.164 number via variable mapping (e.g. from a webhook payload)
  • The root cause was that validateAndInferMetadataFromPrimaryPhoneNumber used the nullish coalescing operator (??) to decide whether to infer calling/country codes from the phone number. Since the workflow frontend sends empty strings ('') for unset calling code and country code sub-fields, ?? treated them as valid values and skipped inference.
  • Replaced ?? with isNonEmptyString() checks so that empty strings are treated as "not provided", allowing libphonenumber-js to correctly parse and infer both calling code and country code from E.164 formatted phone numbers.
  • Added unit tests for transformPhonesValue covering E.164 inference, explicit values, and edge cases.

Test plan

  • Verify that a Workflow with a webhook trigger mapping an E.164 phone number (e.g. +919999999999) to a Phone field correctly stores calling code (+91) and country code (IN)
  • Verify that explicitly setting calling code and country code in the workflow form still works correctly
  • Verify that API-level phone number creation still works as before
  • Run transformPhonesValue unit tests

Fixes #17182

…workflows

When a workflow maps a variable containing an E.164 phone number (e.g.
"+919999999999") to a phone field, the calling code and country code
sub-fields are sent as empty strings. The nullish coalescing operator
(??) treated these empty strings as valid values, preventing the
backend from inferring the calling code and country from the E.164
number itself.

Replace ?? with isNonEmptyString() checks so that empty strings are
treated as "not provided", allowing libphonenumber-js to correctly
infer calling code and country code from the phone number.

Fixes twentyhq#17182
Copy link
Copy Markdown
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Your free trial has ended. If you'd like to continue receiving code reviews, you can add a payment method here.

@github-actions
Copy link
Copy Markdown
Contributor

Welcome!

Hello there, congrats on your first PR! We're excited to have you contributing to this project.
By submitting your Pull Request, you acknowledge that you agree with the terms of our Contributor License Agreement.

Generated by 🚫 dangerJS against 7bc6542

Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 2 files

@charlesBochet
Copy link
Copy Markdown
Member

@jnMetaCode Please stop opening AI generated PR on this repository. You are not helping us and harming the community. This will be the only warning before ban: one more and that's it

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.

Workflow Create Record cannot fully populate Phone field (country selector not mappable)

2 participants