Skip to content

Instantly share code, notes, and snippets.

@wvpv
Created December 10, 2019 14:59
Show Gist options
  • Save wvpv/d39ee39345f799fc0193b416a7b5e2e0 to your computer and use it in GitHub Desktop.
Save wvpv/d39ee39345f799fc0193b416a7b5e2e0 to your computer and use it in GitHub Desktop.
Query to pull PushAddress data
select
_ContactID ContactID
, _DeviceID DeviceID
, _APID APID
, _Status Status
, _Source Source
, _SourceObjectId SourceObjectId
, _Platform Platform
, _PlatformVersion PlatformVersion
, _Alias Alias
, _OptOutStatusID OptOutStatusID
, _OptOutMethodID OptOutMethodID
, _OptOutDate OptOutDate
, _OptInStatusID OptInStatusID
, _OptInMethodID OptInMethodID
, _OptInDate OptInDate
, _Channel Channel
, _CreatedDate CreatedDate
, _CreatedBy CreatedBy
, _ModifiedDate ModifiedDate
, _ModifiedBy ModifiedBy
, _City City
, _State State
, _ZipCode ZipCode
, _FirstName FirstName
, _LastName LastName
, _UTCOffset UTCOffset
, _IsHonorDST IsHonorDST
, _SystemToken SystemToken
, _ProviderToken ProviderToken
, _Badge Badge
, _LocationEnabled LocationEnabled
, _TimeZone TimeZone
, _Device Device
, _HardwareId HardwareId
, _DeviceType DeviceType
from _PushAddress
@argenisperez
Copy link

In order this SQL works in Query studio I had to some changes

select
_ContactID as ContactID,
_DeviceID as DeviceID,
_APID as APID,
_Status as Status,
_Source as Source,
_SourceObjectId as SourceObjectId,
_Platform as Platform,
_PlatformVersion as PlatformVersion,
_Alias as Alias,
_OptOutStatusID as OptOutStatusID,
_OptOutMethodID as OptOutMethodID,
_OptOutDate as OptOutDate,
_OptInStatusID as OptInStatusID,
_OptInMethodID as OptInMethodID,
_OptInDate as OptInDate,
_Channel as Channel,
_CreatedDate as CreatedDate,
_CreatedBy as CreatedBy,
_ModifiedDate as ModifiedDate,
_ModifiedBy as ModifiedBy,
_City as City,
_State as State,
_ZipCode as ZipCode,
_FirstName as FirstName,
_LastName as LastName,
_UTCOffset as UTCOffset,
_IsHonorDST as IsHonorDST,
_SystemToken as SystemToken,
_ProviderToken as ProviderToken,
_Badge as Badge,
_LocationEnabled as LocationEnabled,
_TimeZone as TimeZone,
_Device as Device,
_HardwareId as HardwareId,
_DeviceType as DeviceType
from _PushAddress

@wvpv
Copy link
Author

wvpv commented Jan 6, 2020

Like what? I've used my query in SFMC without any issue.

@argenisperez
Copy link

This is the error that i am getting running the SQl on Quesry studio in SFMC

Anotación 2020-01-06 164430

@wvpv
Copy link
Author

wvpv commented Jan 6, 2020

Appears to be an issue isolated to Query Studio.

image

@argenisperez
Copy link

Thanks for share.
have a great year 2020

@argenisperez
Copy link

Hi Adam
I am trying to send a mobile push notification on a test app uploaded via usb cable for testing propose

Do you know How I can update the Status fiel on _Pushaddress. I wish chante the status from "No Opted in" to "Opted in"

Anotación 2020-01-07 103511

@rodrigofreitasit
Copy link

rodrigofreitasit commented Feb 13, 2020

@argenisperez you need sent this informations by API contacts/v1/contacts
Method PATCH
And this fields below

{
"name": "MobilePush Subscriptions",
"items": [{
"values": [{
"name": "Device ID",
"value": "VALUE"
},
{
"name": "Application",
"value": "VALUE"
},
{
"name": "Opt In Status",
"value": 2
},
{
"name": "Opt In Method",
"value": 13
},
{
"name": "Opt In Date",
"value":"DATE"
}
]
}]
}]

@MichalSkrisa
Copy link

Hi Adam, is there any way to retrieve App Version number?
image

@wvpv
Copy link
Author

wvpv commented Feb 3, 2021

_APID perhaps?

@MichalSkrisa
Copy link

_APID is really close :) but it's just an ID of the App

@bsldesigns
Copy link

select
_ContactID as ContactID,
_DeviceID as DeviceID,
_APID as APID,
_Status as Status,
_Source as Source,
_SourceObjectId as SourceObjectId,
_Platform as Platform,
_PlatformVersion as PlatformVersion,
_Alias as Alias,
_OptOutStatusID as OptOutStatusID,
_OptOutMethodID as OptOutMethodID,
_OptOutDate as OptOutDate,
_OptInStatusID as OptInStatusID,
_OptInMethodID as OptInMethodID,
_OptInDate as OptInDate,
_Channel as Channel,
_CreatedDate as CreatedDate,
_CreatedBy as CreatedBy,
_ModifiedDate as ModifiedDate,
_ModifiedBy as ModifiedBy,
_City as City,
_State as State,
_ZipCode as ZipCode,
_FirstName as FirstName,
_LastName as LastName,
_UTCOffset as UTCOffset,
_IsHonorDST as IsHonorDST,
_SystemToken as SystemToken,
_ProviderToken as ProviderToken,
_Badge as Badge,
_LocationEnabled as LocationEnabled,
_TimeZone as TimeZone,
_Device as Device,
_HardwareId as HardwareId,
_DeviceType as DeviceType
from _PushAddress

I receive the following error: Could not convert date and/or time from string data type. - Any quick tips on how to resolve in Query Studio?

@wvpv
Copy link
Author

wvpv commented Jun 23, 2021

You'll need to convert any dates to varchar data types, because apparently Query Studio can't figure that out. For example: convert(varchar(50), _CreatedDate) as CreatedDate,

@Resacek
Copy link

Resacek commented Apr 19, 2022

Hello guys
Please help, what API can I use to retrieve the fields from _PushAddress data view? Just in case SF adds some more fields in the data views. Thanks.

@wvpv
Copy link
Author

wvpv commented Apr 19, 2022

[...] what API can I use to retrieve the fields from _PushAddress data view? Just in case SF adds some more fields in the data views.

AFAIK, this data is not exposed to the web services.

@mondrus
Copy link

mondrus commented May 3, 2022

[...] what API can I use to retrieve the fields from _PushAddress data view? Just in case SF adds some more fields in the data views.

AFAIK, this data is not exposed to the web services.

Do you know if this data is available by SQL? (the custom attributes I mean)

@SamuelSteinborn
Copy link

Hi there,
I noticed that the ContacID is not the ContactKey used in MC.
Is there any way to connect the MobilePush ContactID to the AllSubs ContactKey?

@wvpv
Copy link
Author

wvpv commented Feb 17, 2023

Hi there, I noticed that the ContacID is not the ContactKey used in MC. Is there any way to connect the MobilePush ContactID to the AllSubs ContactKey?

Here's a response on that topic from Bill Mote who works at SF: https://salesforce.stackexchange.com/a/313851/5202

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment