I am new to the API and I am trying to change a virtual field that I have mapping to the Acknowledged field. I want it to change to Not Acknowledged if the constituent record is added to today.
Can someone help with this code.
Are you sure, when the record was added today, that the values "oRec.Fields(Blackbaud.PIA.RE7.
msgbox ("Constit Date = " & oRec.Fields(Blackbaud.PIA.RE7.
The way you are currently comparing is a string comparison (as opposed to a date comparison) so if any part of the string is even the tiniest bit different then the values will not be considered equal. To do a date comparison, you may want to convert both values using CDate (haven't tried it, but ought to work).
Public Overrides Sub AfterConstituentSave(ByVal oRec As Blackbaud.PIA.RE7.BBREAPI.CRecord, ByVal Cancel As ImportOM.API.iCancel)
'msgbox ("Constit Date = " & oRec.Fields(Blackbaud.PIA.RE7.BBREAPI.ERECORDSFields.RECORDS_fld_DATE_ADDED) & VbCrLf & "Today = " & DateTime.Today.ToString("d"))
If oRec.Fields(Blackbaud.PIA.RE7.BBREAPI.ERECORDSFields.RECORDS_fld_DATE_ADDED) = DateTime.Today.ToString("d") Then
But (you will be unsurprised to hear), that didn't work. So, I'm back to thinking about date formats...