Question

Photo of Shawn Ross

0

Dynamic Data Block - Proper SQL referencing 'Mobile' phone # ??

I have a Dynamic Data Block I'm using with the following 'parameters' for some guest follow-up procedures:

  • Display anyone added to Rock within the last X hours
  • Show their Name
  • What is their email address
  • What is their Mobile Phone #
  • Is SMS enabled on their phone #
  • When were they entered

I have 3 slightly different versions:

  • one that shows SMS-enabled person's (48 hrs entry window)
  • one that shows email person's that don't have SMS enabled (48 hours entry window)
  • one that shows everyone and everything within 72 hours (the catch-all)

What I need some clarification and affirmation of:

  • Is my query for only people with a 'mobile' number that's SMS-enabled correct?

The SQL I'm using. This is my 'catch-all':
(developed in Slack #SQL with @chrisrea, @mikejd, and @paschott)

SELECT
    p.Id
    , p.NickName + ' ' + p.LastName AS 'Name'
    , pn.NumberFormatted AS 'phone'
    , pn.IsMessagingEnabled AS 'SMS Enabled?'
    , p.Email
    , p.CreatedDateTime
FROM Person AS p
LEFT JOIN PhoneNumber AS pn
    ON pn.PersonId = p.Id
WHERE p.CreatedDateTime >= DATEADD( dd, -3, GETDATE())
;

The SQL query I'm using to limit for those with an SMS-enabled mobile #...is this correct?:

SELECT
    p.Id
    , p.NickName + ' ' + p.LastName AS 'Name'

    , pn.NumberFormatted AS 'Mobile phone'
    , pn.IsMessagingEnabled AS 'SMS Enabled?'
    , p.Email
    , p.CreatedDateTime
    , pn.NumberTypeValueId
FROM Person AS p
LEFT JOIN PhoneNumber AS pn
    ON pn.PersonId = p.Id
WHERE p.CreatedDateTime >= DATEADD( dd, -3, GETDATE())
    AND pn.IsMessagingEnabled = 1
    AND pn.NumberTypeValueId = 12
;

  • Photo of Jeremy Hoff

    1

    Hi Shawn:


    • Is my query for only people with a 'mobile' number that's SMS-enabled correct?


    Yes, that's how I read it - phonetypeID = 12 is the default ID for mobile numbers.