IOM matches Constituents based on Phone Numbers, but it won't match Phone Numbers based on Phone Numbers. It first needs to match on Phone Type, and then it checks to see if the Phone Numbers match (correct me if I'm wrong about this at any point).
On a regular basis, I have incoming lists of Phone Numbers (with associated Constituent IDs) which are no longer valid. I can't remove them en-masse from RE (and I'm not sure I'd want to - I don't entirely trust the data source), but I can change theirassociated Phone Types to highlight their dubious accuracy. So I'd like to do that.
Unfortunately, I don't see how. Since IOM uses Phone Type for the match, it appears impossible to change the Phone Types in RE using IOM. Am I right?
I just talked to someone else with a very similar problem. Below is a possible solution using the API
I would do something like this in AfterConstituentOpen: [code] ‘ Initialize variables Dim sNumber As String Dim sType As String Dim iPhone As IBBPhone ‘ Set import values to compare sNumber = Import.Fields.GetByName(“PhoneNumber”).Value sType = Import.Fields.GetByName(“PhoneType”).Value ‘ Loop through each phone on the preferred address to look for a match For Each iPhone In oRec.PreferredAddress.Phones ‘ Check if the current number matches the import number If String.Compare(sNumber, iPhone.Fields(EPhonesFields.Phone_fld_Num), True) = 0 Then ‘ If the number matches then set the type to the import type iPhone.Fields(EPhonesFields.Phone_fld_PhoneType) = sType Exit For End If Next iPhone [/code]
W
Wayne Pozzar
said
over 7 years ago
Sorry, this assumes that you have the line:
Imports Blackbaud.PIA.RE7.BBREAPI
At the top of your script
E
Evan Rodwell
said
over 7 years ago
Thanks, Wayne. I finally got back to this.
It seems IBBPhone isn't a defined type. Is there a code table I need to edit somewhere?
W
Wayne Pozzar
said
over 7 years ago
see my second comment about adding Imports Blackbaud.PIA.RE7.BBREAPI to the top of your script.
In reality the type is: Blackbaud.PIA.RE7.BBREAPI.IBBPhone
E
Evan Rodwell
said
over 7 years ago
That makes sense. Thanks.
E
Evan Rodwell
said
over 7 years ago
It works!
Thanks, Wayne. I had to tweak it a tiny bit because I don't actually have the PhoneType in my import file, so I'm using a virtual field for that, but it works.
You're a wizard.
W
Wayne Pozzar
said
over 7 years ago
Awesome! Glad to hear it and nice work modifying it, shows that you know what's going on.
J
Jordan Gillis
said
over 7 years ago
Hey guys, am I just blind? I don't see AfterConstituentOpen in my list. The only After* I see is AfterDictionary, AfterImport, AfterRowCommit.
Thanks a million for your help!
W
Wayne Pozzar
said
over 7 years ago
Not blind Jordan.
You have to add it. Just type "Public Overrides" in the editor and a list will come up and you can select AfterConstituentOpen.
J
Jordan Gillis
said
over 7 years ago
Look at that, thanks a million!
E
Evan Rodwell
said
over 7 years ago
I can't get the code format right. Let me try again.
E
Evan Rodwell
said
over 7 years ago
I did ultimately decide to use this to delete phone numbers from my database. Here's the code:
[code] 'Initialize variables Dim sNumber As String Dim sType As String Dim iAddress As _CConstitAddress Dim iPhone As IBBPhone 'Set import values to compare sNumber = Import.Fields.GetByName(“PhoneNumber”).Value 'Examine each address on the constituent For Each iAddress In oRec.Addresses 'Examine each phone number on that address For Each iPhone In iAddress.Phones 'Check if the phone number matches the import number If String.Compare(sNumber, iPhone.Fields(EPhonesFields.Phone_fld_Num), True) = 0 Then 'If yes, then delete that phone entry from that address iAddress.Phones.Remove(iPhone) Exit For End If Next iPhone Next iAddress [/code]
Now the question is, would this work with Null values? Could I use this (or something like it) to remove blank phone numbers (they have a Phone Type, but no Phone Number) from my database?
W
Wayne Pozzar
said
over 7 years ago
Sure, should be easy enough.
Replace
If String.Compare(sNumber, iPhone.Fields(EPhonesFields.Phone_fld_Num), True) = 0 Then
with
If iPhone.Fields(EPhonesFields.Phone_fld_Num) = "" Then
J
Jordan Gillis
said
over 7 years ago
Wayne,
Is there a way to check if the phone type is "Private Email" for example and to skip the record if the import value matches that specific phone value? All my efforts seem to fall flat. Admittedly my coding skills are rudimentary.
Evan Rodwell
IOM matches Constituents based on Phone Numbers, but it won't match Phone Numbers based on Phone Numbers. It first needs to match on Phone Type, and then it checks to see if the Phone Numbers match (correct me if I'm wrong about this at any point).
On a regular basis, I have incoming lists of Phone Numbers (with associated Constituent IDs) which are no longer valid. I can't remove them en-masse from RE (and I'm not sure I'd want to - I don't entirely trust the data source), but I can change theirassociated Phone Types to highlight their dubious accuracy. So I'd like to do that.
Unfortunately, I don't see how. Since IOM uses Phone Type for the match, it appears impossible to change the Phone Types in RE using IOM. Am I right?