We are a group of users of Blackbaud products and are not affiliated with Blackbaud. We'd love to have you join our community to help and be helped in getting the most from your Blackbaud software.
Register now to join us to get independant advice on your system, connect with 3rd party consultants to help you maximize your database and have a real alternative to the official Blackbaud website.
Hi everyone,
I'm very new to RE and RE/VBA. I’m trying to create a small plug-in. It imports gifts. I have to use a batch. Each gift has an attribute with code CGO. When I save the gift directly (without batch) the attribute has been added correctly. But if I add the gifts to a batch and then submit the batch the attributes are missing. Probably my problem is how to add gift attribute filed to the batch.
I would appreciate any help. This is the code I use in order to create the batch:
Private Sub CreateNewBatch()
Dim BatchName As String
BatchName = "Custom Batch" + Date$ + " " + Time$
Set oBatch = New CBatchAPI
oBatch.Init REAPI.SessionContext
oBatch.Fields(BATCHAPI_fld_BATCH_NUMER) = BatchName
oBatch.Fields(BATCHAPI_fld_DESCRIPTION) = Some Gifts"
oBatch.Fields(BATCHAPI_fld_OTHERS_CAN_MODIFY) = True
'Add batch fields
Dim oBatchFields As CBatchFields
Set oBatchFields = oBatch.BatchFields
With oBatchFields
' ??????????????????????????????????????? ' ADD A gift attribute field - attribute code CGO
End With
oBatch.Save
Set oBatchFields = Nothing
Set oTempRecords = oBatch.TempRecords
End Sub
Private Sub SetupBatchField(ByVal oBatchField As CBatchField, ByVal lGiftField As EGiftFields)
With oBatchField
.Fields(BatchField_fld_MetaObjectId) = bbmoGIFT
.Fields(BatchField_fld_FieldNumber) = lGiftField
End With
End Sub
Thank you in advance!!!
__________________ Ivan Vasilev Database Manager USA, Atlanta, GA
To add attributes you need a new SetupBatchField function specfically for attributes. Something like the following:
Code:
Private Sub SetupBatchAttributeField(ByVal oBatchField As CBatchField, ByVal lAttributeField As EattributeFields)
With oBatchField
.Fields(BatchField_fld_MetaObjectId) = bbmoGIFT_ATTRIBUTE
.Fields(BatchField_fld_FieldNumber) = lAttributeField
End With
End Sub
I added the code and now I see the attribute field as a batch field. Actually I see the description of the attribute I needed. When I add a gift, an attribute is added but the value of the attribute is not assigned. This is the procedure I use in order to add a gift: Public Sub AddGift(....) Dim oGift As CGift Set oGift = New CGift
With oGift .Init REAPI.SessionContext
' Init Gift’s fields ......
'ADD Credit Card Information ...... End With
' Add Attribute With oGift.Attributes.Add .Fields(Attribute_fld_ATTRIBUTETYPES_ID) = lAttributeID .Fields(Attribute_fld_VALUE) = True ' Yes/No attribute End With
'AddGiftToBatch oGift Dim oTempRecord As CTempRecord Dim oTempRecords As CTempRecords
Set oTempRecords = oBatch.TempRecords Set oTempRecord = oTempRecords.Add Set oTempRecord.DataObject = oGift
oGift.CloseDown Set oGift = Nothing End Sub
I don’t know if this is the only way to add a gift to a batch. I wish the documentation had more information.
I really appreciate your help!!!
Ivan
__________________ Ivan Vasilev Database Manager USA, Atlanta, GA
The lAttributeField value is the field of the attribute object. So if you have a an attribute attrib and normally you wanted to get or set the value of say the date you would write:
So your value for lAttributeField in the above example would be Attribute_fld_ATTRIBUTEDATE. That way the batch knows which field you are refering to in the batch.
This is an example:
.......................
SetupBatchFieldAttribute .Add(), Attribute_fld_VALUE, "Online Gift", "E-Store"
' the rest of the fields you can find from RE7Objects.chm
.......................
Private Sub SetupBatchFieldAttribute(ByVal oBatchField As CBatchField, ByVal lGiftAttributeField As EattributeFields, GiftAttributeType As String, GiftAttributeDefaultValue As String)
With oBatchField
.Fields(BatchField_fld_MetaObjectId) = bbmoGIFT_ATTRIBUTE
.Fields(BatchField_fld_FieldNumber) = lGiftAttributeField
.Fields(BatchField_fld_ObjectID) = getGiftAttributeID(GiftAttributeType) ' my sub-returns attribute ID
.Fields(BatchField_fld_ObjectSequence) = 1
.Fields(BatchField_fld_DefaultData) = GiftAttributeDefaultValue
End With
End Sub
But I don't have any idea how to control the value of the attribute. If the attribute is Yes/No an attribute is added to the gift but the default value is not assigned. If the attribute is another type - usually it is not added to the gift. Submitting of gift trough batch is a full mystery for me. (I’m very, very new in RE )
__________________ Ivan Vasilev Database Manager USA, Atlanta, GA
----------------------------------------------------------- 'Add gift "oGift" to batch "oBatch" Dim oTempRecord As BatchData7.CTempRecord Dim oTempRecords As CTempRecords
Set oTempRecords = oBatch.TempRecords Set oTempRecord = oTempRecords.Add
' add the gift Set oTempRecord.DataObject = oGift
' add attribute value - in this case the 20-th batch field is my attribute's value oTempRecord.Fields(20) = "Attribute Value"
-----------------------------------------------------------
*note - be sure to add a reference to "Blackbaud RE Batch Data Objects 7.5"
__________________ Ivan Vasilev Database Manager USA, Atlanta, GA
The following code is from this thread. I'm assuming this line is expressing that the field being added to the batch, is a Gift field:
.Fields(BatchField_fld_MetaObjectId) = bbmoGIFT
I'm pretty close in terms of creating a gift batch with Visual Studio and VB.NET, but I cannot figure out what the bbmoGIFT is and it's preventing my code from running. Is it an Enum that I somehow do not have a reference to.
I have written up this solution on my blog. I often write these things up so that they are easily accessible to me so a lot of thanks goes to Ivan for figuring it out. Here is the link if you are interested:
For whatever reason, when I add this field to the batch...
SetupBatchField .Add(), GIFT_fld_Constit_ID
...and then open the batch in Raisers Edge, it does not have a field for the Constituent ID and additionally it does have a field named 'Consitituent name' that I did not add.
How do I programaticly create a batch with a field for 'Constituent ID'?