 | | Notices |
Welcome to the Blackbaud User Society!
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.
|  | |
01-31-2008, 08:07 AM
|
#1 (permalink)
| | Junior Member Join Date: Jan 2008 Location: Atlanta, GA
Posts: 13
Downloads: 33 Uploads: 0 Rep Power: 0  | API help with Gifts with Attribute 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
SetupBatchField .Add(), GIFT_fld_Constit_ID
SetupBatchField .Add(), GIFT_fld_Type
SetupBatchField .Add(), GIFT_fld_Amount
SetupBatchField .Add(), GIFT_fld_Payment_Type
SetupBatchField .Add(), GIFT_fld_Credit_Type
SetupBatchField .Add(), GIFT_fld_Credit_Card_Number
SetupBatchField .Add(), GIFT_fld_CardholderName
SetupBatchField .Add(), GIFT_fld_Expires_On
SetupBatchField .Add(), GIFT_fld_Authorization_Code
SetupBatchField .Add(), GIFT_fld_Date
SetupBatchField .Add(), GIFT_fld_Post_Date
SetupBatchField .Add(), GIFT_fld_Campaign
SetupBatchField .Add(), GIFT_fld_Fund
SetupBatchField .Add(), GIFT_fld_Appeal
SetupBatchField .Add(), GIFT_fld_Acknowledge_Date
SetupBatchField .Add(), GIFT_fld_Receipt_Number
SetupBatchField .Add(), GIFT_fld_Receipt_Amount
SetupBatchField .Add(), GIFT_fld_Post_Status
SetupBatchField .Add(), GIFT_fld_Reference ' ??????????????????????????????????????? ' 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 |
02-04-2008, 07:38 AM
|
#2 (permalink)
| | Likes to customize RE! Join Date: Jul 2006 Location: London, UK
Posts: 421
Downloads: 6 Uploads: 0 Rep Power: 3  | Ivan,
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
Let me know if you need any more help
David |
02-05-2008, 06:28 PM
|
#3 (permalink)
| | Junior Member Join Date: Jan 2008 Location: Atlanta, GA
Posts: 13
Downloads: 33 Uploads: 0 Rep Power: 0  | David, Thank you very much!!! 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 |
02-27-2008, 06:11 PM
|
#4 (permalink)
| | Junior Member Join Date: Feb 2008 Location: Newcastle, Australia
Posts: 4
Downloads: 1 Uploads: 0 Rep Power: 0  | David,
I have the same problem, however I'm still a bit confused. As you suggested above, I've created a SetupBatchAttributeField procedure.
What I don't understand is, what value do I pass to this procedure for lAttributeField?
Thanks in advance for any help. |
02-28-2008, 06:11 AM
|
#5 (permalink)
| | Likes to customize RE! Join Date: Jul 2006 Location: London, UK
Posts: 421
Downloads: 6 Uploads: 0 Rep Power: 3  | 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:
attrib.Fields(Attribute_fld_ATTRIBUTEDATE) = Now()
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.
David |
02-28-2008, 06:46 AM
|
#6 (permalink)
| | Junior Member Join Date: Jan 2008 Location: Atlanta, GA
Posts: 13
Downloads: 33 Uploads: 0 Rep Power: 0  | 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 |
02-28-2008, 09:09 PM
|
#7 (permalink)
| | Junior Member Join Date: Feb 2008 Location: Newcastle, Australia
Posts: 4
Downloads: 1 Uploads: 0 Rep Power: 0  | Thanks Ivan, that worked nicely.
I'm still having the same problem as you though, where the attributes in the batch are all empty.
If you put a breakpoint on this line, where the gift is added into the batch: Code: Set oTempRecord.DataObject = oGift
It seems that oGift has the attributes set correctly.
But after you get past that line "oTempRecord.DataObject" has lost all the attributes. They are all empty except for the Yes/No fields.
There must be something else that needs to be done to the attribute values before adding the gift to the batch. I've tried: - setting the attribute values after adding the gift to the batch
- setting the attribute date and comment fields
- setting the attribute import ID to the type ID
- setting the attribute sequence field to different values
- using a transaction around adding the attributes:
Code: oGift.Attributes.BeginCollectionTransaction
...
oGift.Attributes.CommitCollectionTransaction
Nothing seems to work.
Let me know if you figure it out, I know I can't  |
03-03-2008, 04:58 PM
|
#9 (permalink)
| | Junior Member Join Date: Jan 2008 Location: Atlanta, GA
Posts: 13
Downloads: 33 Uploads: 0 Rep Power: 0  | Ok, this works:
----------------------------------------------------------- '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 |
03-04-2008, 10:56 PM
|
#10 (permalink)
| | Junior Member Join Date: Feb 2008 Location: Newcastle, Australia
Posts: 4
Downloads: 1 Uploads: 0 Rep Power: 0  | that works well, thanks for all your help Ivan. |
03-06-2008, 09:47 AM
|
#11 (permalink)
| | Likes to customize RE! Join Date: Jul 2006 Location: London, UK
Posts: 421
Downloads: 6 Uploads: 0 Rep Power: 3  | Nice solution Ivan!
David |
07-09-2008, 06:30 PM
|
#12 (permalink)
| | jellyfish Join Date: Jul 2008 Location: Marina
Posts: 5
Downloads: 0 Uploads: 0 Rep Power: 0  | help with the bbmoGIFT 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.
Thanks in advance for help |
07-09-2008, 07:00 PM
|
#13 (permalink)
| | Junior Member Join Date: Feb 2008 Location: Newcastle, Australia
Posts: 4
Downloads: 1 Uploads: 0 Rep Power: 0  | bbmoGIFT is in an enum called bbMetaObjects.
so your line of code would be:
.Fields(EBatchFieldFields.BatchField_fld_MetaObjectId) = bbMetaObjects.bbmoGIFT |
07-10-2008, 08:16 AM
|
#14 (permalink)
| | Likes to customize RE! Join Date: Jul 2006 Location: London, UK
Posts: 421
Downloads: 6 Uploads: 0 Rep Power: 3  | 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: RE-Decoded » Blog Archive » Creating Attributes with the BatchAPI
David |
07-13-2008, 02:45 AM
|
#15 (permalink)
| | jellyfish Join Date: Jul 2008 Location: Marina
Posts: 5
Downloads: 0 Uploads: 0 Rep Power: 0  | GIFT_fld_Constit_ID 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'?
Thanks all,
Don |
07-14-2008, 05:59 AM
|
#16 (permalink)
| | Likes to customize RE! Join Date: Jul 2006 Location: London, UK
Posts: 421
Downloads: 6 Uploads: 0 Rep Power: 3  | The field GIFT_fld_Constit_ID does not represent the constituent ID. It represents the system Id of the constituent. As far as I remember correctly this isthe only way of specifying which constituent is to be added to the batch. I am sure that there is a way of showing the constituent ID instead of the name but I have not worked it out yet.
David |
07-17-2008, 07:34 AM
|
#17 (permalink)
| | Junior Member Join Date: Jan 2008 Location: Atlanta, GA
Posts: 13
Downloads: 33 Uploads: 0 Rep Power: 0  | Use code 10200 for a constituent ID(not record ID, not constituent name). Example:
SetupBatchField .Add(), 10200 Don't ask me why 
__________________ Ivan Vasilev Database Manager USA, Atlanta, GA |
07-17-2008, 08:24 AM
|
#18 (permalink)
| | Likes to customize RE! Join Date: Jul 2006 Location: London, UK
Posts: 421
Downloads: 6 Uploads: 0 Rep Power: 3  | Out of interest where did you find that code?
David |
07-17-2008, 09:04 AM
|
#19 (permalink)
| | Junior Member Join Date: Jan 2008 Location: Atlanta, GA
Posts: 13
Downloads: 33 Uploads: 0 Rep Power: 0  | I don’t have an official document. I examined a batch created trough RE. Then I tested the code and it worked.
__________________ Ivan Vasilev Database Manager USA, Atlanta, GA |
07-22-2008, 10:16 AM
|
#20 (permalink)
| | Junior Member Join Date: Jan 2008 Location: Atlanta, GA
Posts: 13
Downloads: 33 Uploads: 0 Rep Power: 0  | A few additional codes:
10200 : Constituent ID
10201 : Gift Barcode
10202 : Rejection code
__________________ Ivan Vasilev Database Manager USA, Atlanta, GA |  | | |
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | | | | Thread Tools | | | | Display Modes | Linear Mode |
Posting Rules
| You may not post new threads You may not post replies You may not post attachments You may not edit your posts HTML code is Off | | | All times are GMT -6. The time now is 07:18 PM. |  |