TR_QUERY_ELEMENT "Phone" vs "T_Phone" in Data From field

Hi, I've noticed many default tables referenced in the "Data From" field in TR_QUERY_ELEMENT that are titled similarly to existing official tables. A couple examples would be "Phone" compared to "T_PHONE" and "Customer" compared to "T_Customer". What table or view do these "Phone" and "Customer" tables reference? I ask because we are running into a problem where several constituents are having their phone type = 1 appear when pulling from the record in TR_QUERY_ELEMENT with "Data Select = phone2" and "Data From = Phone". This is confusing our Development team.
  • Aaron, This question really grabbed my curiosity so I took a look myself. I created an Output Set using Phone 1 and Phone 2 from a list, which is set up in TR_QUERY_ELEMENT and should be pulling phone1 and phone2 respectively. If you look under TR_PHONE_TYPE, you'll also find that Phone 1 and Phone 2 are even set as ID 1 and 2 in that table by default. However, when running the Output Set against my own constituent record with a Phone 1 and Phone 2 on the account, the Output Set report cites nothing under Phone 1 and the Phone 1 value under Phone 2. Definitely would seem worth sharing with the Tessitura team to see what might be happening here. Thank you, Brian
  • I'm filing a TASK question about this curiosity now. I'll let you know what its all about.
  • The answers you seek, my friends, are in the RP_RUN_QUERY and AP_GET_PHONES stored procedures. This piqued my interest as well since I've been digging around the output set logic related to salutations recently.

    The "Data From" items in TR_QUERY_ELEMENT that you mention are a kind of virtual tables that are created behind the scenes by RP_RUN_QUERY when you execute an output set. The reason for this is to apply selection logic to things like addresses and salutations based on the parameters you use to execute your query. In the case of phones, I believe the purpose of using the virtual table is that if you have different phones on multiple addresses, the phones returned will be the ones attached to the _address_ that is selected for the constituent (even if no address fields are present in your output).

    The other wrinkle here is the actual behavior of AP_GET_PHONES. If you look closely, the return value of Phone 1 (in this procedure known as @day_phone) is actually any phone number for the constituent with a TR_PHONE_TYPE id of 7 — on my system, this is a Work phone (I believe that's what's configured out of the box, but I'm not sure). The return value of Phone 2, in this procedure known as @eve_phone, is... you guessed it, a phone on the selected address with a type ID of 1, which is used for "phone 1" on an address.

    It smells like a bug to me, or at the least undocumented behavior. (Who would have guessed that phone type 7 was so special?) But there is one more thing — AP_GET_PHONES actually provides for a DBA to replace its behavior with whatever localized logic you want in LP_GET_PHONES. So you _could_ fix this yourself if you were so inclined! (You could also circumvent the virtual table query elements and make your own elements based on a custom view, but the LP_GET_PHONES proc would give you more options).

    P.S. Join us on Slack! Info at https://tessituracoders.bitbucket.io/

  • Kevin, Thanks for sharing the link on that; I'd never noticed it in the documentation! Brian
  • It's always in the last place you look! Kevin, perhaps there should be reference to ID 7's special behavior in the TR_PHONE_TYPE table documentation. I was scouring the documentation around output sets and query elements, and I'm not sure there's anything that would bring you to those standard data output docs if you didn't know what you were looking for already.

  • This behavior for the return of phone numbers is documented on the Phones screen: http://www.tessituranetwork.com/Help_System_v125/Content/Constituent%20Records%20Basic%20Features/Phones%20Screen.htm

     

    It’s also noted at the top of any of the topics listing the standard data output for things like acknowledgements, confirmations, renewal notices, and extractions.

     

    Kevin Sheehan

    Senior Technical Writer & Consultant

    Tessitura Network

    +1 888 643 5778 x 329

    ksheehan@tessituranetwork.com