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.
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!
Presently the code is saved on my desktop as a Word Document titled "Perth Saves Kalamazoo" and I could not be more grateful, Andrew.