Is there a way to set a constituent attribute conditionally during an import? For example, the import file contains incoming values for the attribute. But I want to update the value of the existing attribute (in the target constituent record) only if it meets certain criteria. I have inserted code in the AfterConstituentOpen event to get the existing value of the constituent attribute and determine if it meets the criteria. If it doesn't, I clear the incoming attribute value field(s) in the import file so the existing attribute value is not updated.
I thought this was working; however, I have recently discovered that if there is a value specified for the attribute in the import file, by the time the code in the AfterConstituentOpen event runs to get the existing value of the attribute in the constituent record, the attribute in the constituent record will have already been updated by the incoming data. If I want to be able to check the existing value of an attribute, I have to clear the corresponding incoming data fields before the AfterConstituentOpen event. But then I no longer have the incoming attribute value to update the existing value if I need to.
Value of attribute field in import file is "A"
Value of attribute field in constituent record is "B"
I want to update the attribute in the constituent record to the incoming value "A" if the existing value is "B"
When the code in AfterConstituentOpen is run, it returns the value of the attribute in the constituent record as "A" and as a result, it will not be updated
The code will only return the existing value of the attribute in the constituent record as "B" if I first clear the incoming attribute fields
I don't recall this happening before when I first wrote the code. Has something changed in IOM or is this how it has always been?
More importantly, how do I accomplish what I'm trying to do? Is there another event that fires after the constituent record is opened but before the import file values are loaded into the record? Do I have to create an additional virtual field to temporarily store the incoming attribute value so it can be copied to the actual (mapped) attribute field during the AfterConstituentOpen event if needed? I think I tried this but it didn't seem to work. Is it not possible to set any mapped import field at this point?
Any help is appreciated. Thanks!