Shortest possible version of my problem: with control-grouped email addresses (which we need), the WordFly procedure *as delivered* does not actually look for an eaddress_no that belongs to the appropriate group - or even the ACTUAL eaddress_no from the Eaddress table - it just selects the first row with the same email string (address) that the message was sent to...which means that currently, I have purposes that belong to one organization being written to another organization's email types. PLEASE HELP. WILL SEND COOKIES.
Are you specifically talking about LP_UPDATE_EMAIL_PROMOTION? Our SQL guru, Barbara Sikkink, has modified our code to adapt it for the multiple organizations we work with. I'm just not sure whether or not it does anything different regarding the Eaddress table lookup you're mentioning here.
I'll attach our code here just in case it helps.
USE [impresario] GO /****** Object: StoredProcedure [dbo].[LP_UPDATE_EMAIL_PROMOTION] Script Date: 8/6/2020 2:29:21 PM ******/ SET ANSI_NULLS OFF GO SET QUOTED_IDENTIFIER OFF GO ALTER Procedure [dbo].[LP_UPDATE_EMAIL_PROMOTION]( @source_no int = null, @customer_no int = null, @response_code int = null, @response_dt datetime = null, @eaddress varchar(80) = null, @url varchar(1024) = null ) AS SET NOCOUNT ON /************************************************************************************************* New Localized Procedure CWR 10/31/2003 which is called from WP_UPDATE_EMAIL_PROMOTION to optionally take additional actions upon receiving email response notifications Updated 4/10/17 - CMP, Removed error causing comments, commented out CSI creations Sample code is provided below to illustrate some possible actions, especially dealing with Unsubscribe events (response_code 5) Updated 10/2/18 - BLS, updated to add unsubscribe for ahha Tulsa & generic Updated 7/24/19 - BLS, updated to add Gilcrease *************************************************************************************************/ /* start WordFly sample code ========================================================================*/ -- here is code that will set an attribute (hard coded values) If @response_code = 5 -- Philbrook Unsubscribe Begin If Exists (Select * from tx_cust_keyword where customer_no = @customer_no and keyword_no = 215) Update tx_cust_keyword Set key_value = 'Unsubscribe' Where customer_no = @customer_no and keyword_no = 215 Else Insert tx_cust_keyword(customer_no, keyword_no, key_value) Select @customer_no, 215, 'Unsubscribe' End If @response_code = 2 -- Philbrook Hardbounce Begin If Exists (Select * from tx_cust_keyword where customer_no = @customer_no and keyword_no = 215) Update tx_cust_keyword Set key_value = 'Hard Bounce' Where customer_no = @customer_no and keyword_no = 215 Else Insert tx_cust_keyword(customer_no, keyword_no, key_value) Select @customer_no, 215, 'Hard Bounce' End If @response_code = 10 -- ahha Tulsa Unsubscribe Begin If Exists (Select * from tx_cust_keyword where customer_no = @customer_no and keyword_no = 533) Update tx_cust_keyword Set key_value = 'Unsubscribe' Where customer_no = @customer_no and keyword_no = 533 Else Insert tx_cust_keyword(customer_no, keyword_no, key_value) Select @customer_no, 533, 'Unsubscribe' End If @response_code = 7 -- ahha Tulsa Hardbounce Begin If Exists (Select * from tx_cust_keyword where customer_no = @customer_no and keyword_no = 533) Update tx_cust_keyword Set key_value = 'Hard Bounce' Where customer_no = @customer_no and keyword_no = 533 Else Insert tx_cust_keyword(customer_no, keyword_no, key_value) Select @customer_no, 533, 'Hard Bounce' End If @response_code = 15 -- Gilcrease Unsubscribe Begin If Exists (Select * from tx_cust_keyword where customer_no = @customer_no and keyword_no = 590) Update tx_cust_keyword Set key_value = 'Unsubscribe' Where customer_no = @customer_no and keyword_no = 590 Else Insert tx_cust_keyword(customer_no, keyword_no, key_value) Select @customer_no, 590, 'Unsubscribe' End If @response_code = 12 -- Gilcrease Hardbounce Begin If Exists (Select * from tx_cust_keyword where customer_no = @customer_no and keyword_no = 590) Update tx_cust_keyword Set key_value = 'Hard Bounce' Where customer_no = @customer_no and keyword_no = 590 Else Insert tx_cust_keyword(customer_no, keyword_no, key_value) Select @customer_no, 590, 'Hard Bounce' End /* == end WordFly sample code ========================================================================*/ /*== start Tessitura sample code =======================================================================*/ --Declare @errmsg varchar(255), @rowcount int ------ here is code that will set the t_customer emarket_ind to a value dependant on response codes --If @response_code = 5 -- UNSUBSCRIBE: set the marketing indicator on the eaddress record for the customer -- Begin -- Update t_customer -- Set emarket_ind = 5 -- no emarketing to philbrook -- Where customer_no = @customer_no -- End --If @response_code = 2 -- HARDBOUNCE: set the marketing indicator on the eaddress record for the customer -- Begin -- Update t_customer -- Set emarket_ind = 4 -- no emarketing to all organizations -- Where customer_no = @customer_no -- End /* -- E-Marketing Codes 1 - n/a does not exist 2 - "No Emarketing (depriciated) 3 - (none) i.e. No preference 4 - "Do Not Email" 5 - "P Do Not Email" */ /* -- Commented out by Barbara S -- -- here is code that will write a customer service issue (hard coded values) Declare @activity_no int --Philbrook Unsub If @response_code = 5 Begin -- get an issue number EXEC @activity_no = AP_GET_NEXTID_Function 'AC' -- Put in the Customer Service Issue Insert into t_cust_activity( activity_no, category, activity_type, customer_no, contact_type, inout_ind, notes, issue_dt, origin) Select @activity_no, null, 97, @customer_no, 22, 'I', 'WordFly Unsubscribe', getdate(), null End -- Philbrook Hardbounce If @response_code = 2 Begin -- get an issue number EXEC @activity_no = AP_GET_NEXTID_Function 'AC' -- Put in the Customer Service Issue Insert into t_cust_activity( activity_no, category, activity_type, customer_no, contact_type, inout_ind, notes, issue_dt, origin) Select @activity_no, null, 98, @customer_no, 22, 'I', 'WordFly Hard Bounce', getdate(), null End */ --RETURN /*== end Tessitura sample code =======================================================================*/
Sorry - was off for a long weekend to handle some "Parent of 2020 Senior" graduation stuff (note: remote graduation in high school parking lot? not as bad as it sounds) but I'm back now. I'm actually struggling with *this* procedure: LP_WF_PREFERENCE_UPDATE_CUSTOMER and I *think* it's because of this section of the code:
-- STEP 2: FIND EADDRESS RECORD TO MODIFY declare @eaddress_no int select @eaddress_no = eaddress_no from dbo.[t_eaddress] where [customer_no] = @customer_no and [address] = @messaging_address and [inactive] = 'N' order by create_dt desc, last_update_dt desc if ISNULL(@eaddress_no,0) = 0 begin raiserror('Invalid email address for this customer.', 11, 2) with seterror return -101 end
I most definitely cannot have it just looking for the first email address value that it finds that matches the address it was sent to. I need it to match on the *actual* eaddress_no from the T_EADDRESS table, so that if separate orgs have different email types/IDs for the same email address, it attaches the purposes to the correct org. The WordFly code, as delivered, seems to assume that an email address will only exist on a customer record as one email type? ALL help appreciated, and I'm open to "you're doing it wrong" if there's a better way to do this.
Well dang; I just searched our SSMS and I'm seeing six LP's with "WF" in the titles, but none of them are LP_WF_PREFERENCE_UPDATE_CUSTOMER.
For reference, we only have:
Are any of you using WordFly Preferences (which write back to Tessitura as either Interests, Attributes, Contact Point Purposes, or Contact Permissions? That's what this small procedure handles. FTR it works fine for Interests, Attributes, and Permissions, because those are all attached to the customer number, which isn't an issue. But for Purposes, which I would expect to attach to the eaddress_no that was *used* not the VALUE that was used, it's a disaster. Five years in and I've been nagging the orgs for months to start using a combo of purposes and permissions so we can better take advantage of marketing segments and now that two of them have started, I'm finding this mess. I firmly believe I am not able to see a better solution because I'm staring at it like there's only one way to fix it. Hence the crowdsourcing :)
Hi Mindee! Have you talked with WordFly directly about this issue with the email address updates? The consulting team may be able to help with a custom procedure to help update the data the way you need it, but I'm also wondering if this is something larger that WordFly may want to consider in their integration.
Thanks for the suggestion, Colleen. I haven't checked back with WordFly about this yet. Back in January/February when the Arts Council was starting to decide how to configure things, the WordFly support team indicated that changes to that procedure would be our responsibility but I didn't realize at the time (since no one yet had branched out to Preferences/Purposes/Permissions) that the procedure as written would be so unsuitable. I'll reach out and see if they can help.
Mindee Waltz (Past Member) We do have this procedure here in the Perth Consortium and I have attached step 2 of the procedure's contact point purpose section with some modifications. Thanks and hopefully this helps in some way!
-- STEP 2: FIND EADDRESS RECORD TO MODIFY declare @eaddress_no int, @org_id Int, @org_desc VarChar(30), @userid Char(8), @usergroupid Char(8), @control_group Int -- Get organisation I.D. Select @org_id = organization_id From LT_WF_PREFERENCE_HISTORY With (NoLock) Where Id = @preferenceHistoryId -- Get organisation name Select @org_desc = [description] From TR_ORGANIZATION With (NoLock) Where id = @org_id -- Get organisation TMS / WF user name Select @userid = default_value From T_DEFAULTS With (NoLock) Where field_name = 'TMS User' And parent_table = @org_desc -- Get organisation TMS / WF user name's default user group Select @usergroupid = UG_id From TX_USER_GROUP With (NoLock) Where userid = @userid And default_ind = 'y' -- Get organisation TMS / WF user name's default user group's default control group Select @control_group = control_group From TX_CONTROL_GROUP_USER_GROUP With (NoLock) Where ug_id = @usergroupid And default_ind = 'y' -- Try for potential control grouped eaddress_no Set @eaddress_no = (Select Top 1 eaddress_no From T_EADDRESS a With (NoLock) Left Join TR_EADDRESS_TYPE b With (NoLock) On b.id = a.eaddress_type Where a.customer_no = @customer_no And a.[address] = @messaging_address And a.inactive = 'n' And b.control_group = @control_group Order By a.create_dt Desc, a.last_update_dt Desc) -- If not found, try for default uncontrol grouped eaddress_no If IsNull(@eaddress_no, 0) = 0 Begin Set @eaddress_no = (Select Top 1 eaddress_no From T_EADDRESS a With (NoLock) Left Join TR_EADDRESS_TYPE b With (NoLock) On b.id = a.eaddress_type Where a.customer_no = @customer_no And a.[address] = @messaging_address And a.inactive = 'n' And b.control_group = -1 Order By a.create_dt Desc, a.last_update_dt Desc) End /* select @eaddress_no = eaddress_no from dbo.[t_eaddress] where [customer_no] = @customer_no and [address] = @messaging_address and [inactive] = 'N' order by create_dt desc, last_update_dt desc */ if ISNULL(@eaddress_no,0) = 0 begin raiserror('Invalid email address for this customer.', 11, 2) with seterror return -101 end
Bless you, Andrew - I'm going to take a look at this and see whether it works for our group. If nothing else, I can see a first glance that it's going to handle the org separations...!
Andrew, this is a lifesaver. THANK YOU. I think it's going to work *as is* to handle the issue I'm having. I have a meeting with one of the orgs on Wednesday and I will be testing this to see if it's as magical as it seems when I step through it manually.
Mindee Waltz (Past Member) Not a problem and glad I was able to assist. Hopefully it works for you as expected!