CONSTIT_ADDRESS_fld_DATE_TO pointing to wrong field?
S
SeattlePacificUnversity ApplicationsTeam
started a topic
over 6 years ago
Hello!
We are working on creating an import in ImportOMatic but are running into some issues. In particular, we are using the option to “Launch Code Editor” and modify the VB code at runtime. Our use-case is that there are several fields (address to-date, address from-date, street_line2, etc.) for which we want to pass a -value in the import file and have it delete the value in the associated database record (i.e., if our import file has a -value for address to-date but our database record has an existing value for this field, then we want to set the value of the database record to be ).
We have put the following code into the Code Editor to achieve this effect:
Line 1: Required Field Missing: ID [Object: 'CRecord', PK: '786053', Import ID: '00322-593-0000786053', Desc: 'Person1 Name', Field: 'ID', Value: ''] -->BBREAPI.CRecordClass.Save()-->#=qZnYUO34W9Ug0Sg1Q15IR9RtdTFV2RzSiVHkB5ocepf0=.#=qZEQy1A$TkD8X3oMyxbjvbxxMEKT7vx1V0gpzlRGUrOo=()
In the data-file, I am passing 6 records. Given the code above, it fails for all 6 records with the same error message. However, it will process the first record without errors (and fail on the other 5 records) if I hard-code a value for the offending line, ex.:
This leads me to question if somehow the API is pointing to the ID-field when I call CONSTIT_ADDRESS_fld_DATE_TO instead of the address to-date. Can anyone please validate that this API is working correctly? And if so, could I get your assistance in figuring out what I’m doing incorrectly? All of the other fields seem to be working fine when I comment-out this particular line of code; it’s just this single line that is causing problems.
The issue here is that you are using the oRec.fields to set both constituent fields and the address fields, even though oRec is only the constituent. You need to go through orec.addresses collection to find the address you want to update, then set it's field values. Hope that makes sense!
S
SeattlePacificUnversity ApplicationsTeam
said
over 6 years ago
Aha!! Thanks, Jeffrey! This solved my problem. For others' benefit, here was the final version of my code: -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Public Overrides Sub BeforeConstituentSave(ByVal oRec As Blackbaud.PIA.RE7.BBREAPI.CRecord, _ Cancel as ImportOM.API.iCancel) 'The main constitueAfterGiftSave
End Sub --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
J
Jeffrey Montgomery
said
over 6 years ago
Are you SURE the preferred address is the address that should have data removed from it? Could it be you're importing address info that matches to an alternate address?
SeattlePacificUnversity ApplicationsTeam
Hello!
We are working on creating an import in ImportOMatic but are running into some issues. In particular, we are using the option to “Launch Code Editor” and modify the VB code at runtime. Our use-case is that there are several fields (address to-date, address from-date, street_line2, etc.) for which we want to pass a -value in the import file and have it delete the value in the associated database record (i.e., if our import file has a -value for address to-date but our database record has an existing value for this field, then we want to set the value of the database record to be ).
We have put the following code into the Code Editor to achieve this effect:
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Public Overrides Sub BeforeConstituentSave(ByVal oRec As Blackbaud.PIA.RE7.BBREAPI.CRecord, _
Cancel as ImportOM.API.iCancel)
'The main constituent record is about to be saved
orec.Fields(Blackbaud.PIA.RE7.BBREAPI.ERECORDSFields.RECORDS_fld_NICKNAME) = Import.Fields.GetByExcelName("C").Value
orec.Fields(Blackbaud.PIA.RE7.BBREAPI.ERECORDSFields.RECORDS_fld_MIDDLE_NAME) = Import.Fields.GetByExcelName("E").Value
'orec.Fields(Blackbaud.PIA.RE7.BBREAPI.ERECORDSFields.RECORDS_fld_MAIDEN_NAME) = Import.Fields.GetByExcelName("MAIDEN_NAME").Value
orec.Fields(Blackbaud.PIA.RE7.BBREAPI.ECONSTIT_ADDRESSFields.CONSTIT_ADDRESS_fld_DATE_FROM) = Import.Fields.GetByExcelName("J").Value
orec.Fields(Blackbaud.PIA.RE7.BBREAPI.ECONSTIT_ADDRESSFields.CONSTIT_ADDRESS_fld_DATE_TO) = Import.Fields.GetByExcelName("K").Value
orec.Fields(Blackbaud.PIA.RE7.BBREAPI.ECONSTIT_ADDRESSFields.CONSTIT_ADDRESS_fld_COUNTY)= Import.Fields.GetByExcelName("R").Value
orec.Fields(Blackbaud.PIA.RE7.BBREAPI.ECONSTIT_ADDRESSFields.CONSTIT_ADDRESS_fld_COUNTRY)= Import.Fields.GetByExcelName("S").Value
orec.Fields(Blackbaud.PIA.RE7.BBREAPI.ECONSTIT_ADDRESSFields.CONSTIT_ADDRESS_fld_DPC) = Import.Fields.GetByExcelName("T").Value
orec.Fields(Blackbaud.PIA.RE7.BBREAPI.ECONSTIT_ADDRESSFields.CONSTIT_ADDRESS_fld_CARRIER_ROUTE) = Import.Fields.GetByExcelName("U").Value
End Sub
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
However, whenever we run the code, it fails on the following line:
orec.Fields(Blackbaud.PIA.RE7.BBREAPI.ECONSTIT_ADDRESSFields.CONSTIT_ADDRESS_fld_DATE_TO) = Import.Fields.GetByExcelName("K").Value
The error that we receive is:
Line 1: Required Field Missing: ID [Object: 'CRecord', PK: '786053', Import ID: '00322-593-0000786053', Desc: 'Person1 Name', Field: 'ID', Value: ''] -->BBREAPI.CRecordClass.Save()-->#=qZnYUO34W9Ug0Sg1Q15IR9RtdTFV2RzSiVHkB5ocepf0=.#=qZEQy1A$TkD8X3oMyxbjvbxxMEKT7vx1V0gpzlRGUrOo=()
In the data-file, I am passing 6 records. Given the code above, it fails for all 6 records with the same error message. However, it will process the first record without errors (and fail on the other 5 records) if I hard-code a value for the offending line, ex.:
orec.Fields(Blackbaud.PIA.RE7.BBREAPI.ECONSTIT_ADDRESSFields.CONSTIT_ADDRESS_fld_DATE_TO) = “1/1/2020”
The other 5 records fail with these error messages (note that I have removed the actual person names here):
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Line 2: Constituent ID must be unique. [Object: 'CRecord', PK: '607423', Import ID: '00000-079-0000607423', Desc: 'Person1 Name', Field: 'ID', Value: '1/1/2100'] -->BBREAPI.CRecordClass.Save()-->#=qZnYUO34W9Ug0Sg1Q15IR9RtdTFV2RzSiVHkB5ocepf0=.#=qZEQy1A$TkD8X3oMyxbjvbxxMEKT7vx1V0gpzlRGUrOo=()
Line 3: Constituent ID must be unique. [Object: 'CRecord', PK: '786054', Import ID: '00322-593-0000786054', Desc: 'Person2 Name', Field: 'ID', Value: '1/1/2100'] -->BBREAPI.CRecordClass.Save()-->#=qZnYUO34W9Ug0Sg1Q15IR9RtdTFV2RzSiVHkB5ocepf0=.#=qZEQy1A$TkD8X3oMyxbjvbxxMEKT7vx1V0gpzlRGUrOo=()
Line 4: Constituent ID must be unique. [Object: 'CRecord', PK: '770940', Import ID: '00322-593-0000770940', Desc: 'Person3 Name', Field: 'ID', Value: '1/1/2100'] -->BBREAPI.CRecordClass.Save()-->#=qZnYUO34W9Ug0Sg1Q15IR9RtdTFV2RzSiVHkB5ocepf0=.#=qZEQy1A$TkD8X3oMyxbjvbxxMEKT7vx1V0gpzlRGUrOo=()
Line 5: Constituent ID must be unique. [Object: 'CRecord', PK: '786055', Import ID: '00322-593-0000786055', Desc: 'Person4 Name', Field: 'ID', Value: '1/1/2100'] -->BBREAPI.CRecordClass.Save()-->#=qZnYUO34W9Ug0Sg1Q15IR9RtdTFV2RzSiVHkB5ocepf0=.#=qZEQy1A$TkD8X3oMyxbjvbxxMEKT7vx1V0gpzlRGUrOo=()
Line 6: Constituent ID must be unique. [Object: 'CRecord', PK: '786056', Import ID: '00322-593-0000786056', Desc: 'Person5 Name', Field: 'ID', Value: '1/1/2100'] -->BBREAPI.CRecordClass.Save()-->#=qZnYUO34W9Ug0Sg1Q15IR9RtdTFV2RzSiVHkB5ocepf0=.#=qZEQy1A$TkD8X3oMyxbjvbxxMEKT7vx1V0gpzlRGUrOo=()
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
This leads me to question if somehow the API is pointing to the ID-field when I call CONSTIT_ADDRESS_fld_DATE_TO instead of the address to-date. Can anyone please validate that this API is working correctly? And if so, could I get your assistance in figuring out what I’m doing incorrectly? All of the other fields seem to be working fine when I comment-out this particular line of code; it’s just this single line that is causing problems.