I am currently working on a project where I need to copy a gift record from one constituent to another. There are 213 fields on the regular gift object i.e. CGift. That is without looking at any of the other areas of the gift such as attributes, notepads, etc. It would take a lot of typeing to copy between each field so to do this I use the meta data that is supplied with each object.I use the following code:
Dim meta As IBBMetaField meta = CType(origGift, IBBMetaField) For i As Integer = 1 To meta.Count If meta.ReadOnly(i) = False Then newGift.Fields(i) = origGift.Fields(i) End If Next
Here I am using the original gift for my meta data. I use the ReadOnly method to determine whether or not I can enter data into the field. This prevents me from adding data to the Added By field, etc. But this is where the problem lies. Some fields are read only on the original gift but they are not on the new gift. The gift type field only becomes read only when you save it. What is more if the gift if posted then the fund, campaign, appeal, etc fields are also read only.
If we use the new gift’s meta data, very few of the fields are read. This way around we can enter data into fields that are read only on the original such as gift type and fund, etc. The problem is that other fields are not read only so that we end up copying over the constituent id, the import id and other values which should really be unique to the original gift.
Unfortunately there does not appear to be a happy medium. The only way around is to insert a select case looking at the value of i and excluding those id fields. It would have been nice if there had been some kind of indicator showing which fields were given values automatically by the system.
2 thoughts on “Using meta data to copy records”
I do this by hand every month (export and then import). I think the only fields that need changing are gift id, import id, bank import id if standing order (link to bank on new constituent record). I’ve had trouble with payment type if it’s a recurring gift, so I just set to cash. Any notes need copying and relinking to the new gift too.
In my particular example the new gift was going to appear on screen for review. What this meant was that for the bank id field if the bank does not exist on the new constituent’s record then it will be left blank and in the case of direct debits or standing orders the user would have to enter the value before being allowed to save the gift (or else change the payment method to a type that does not require the bank).
You are correct that this could be done using import and export but the solution required that all gift fields, including notes, attributes, tributes, benefits, etc should be included. This could be done by import and export but to set up an automated process is much more efficient for larger numbers which need to be reviewed.
Comments are closed.