Notices



Reply
 
LinkBack Thread Tools Display Modes

Old 01-31-2008, 08:07 AM   #1 (permalink)
Junior Member

Join Date: Jan 2008
Location: Atlanta, GA
Posts: 12
Rep Power: 0 IVasilev is on a distinguished road

Blackbaud Products
- Raiser's Edge (RE)
- API/VBA

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
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote

Old 02-04-2008, 07:38 AM   #2 (permalink)
Likes to customize RE!

DavidZ's Avatar

Join Date: Jul 2006
Location: London, UK
Posts: 310
Rep Power: 3 DavidZ is on a distinguished road

Blackbaud Products
- Raiser's Edge (RE)
- API/VBA

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
__________________
David Zeidman
Zeidman Development
http://www.zeidman.info

Check out my RE API blog
http://www.re-decoded.com

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote

Old 02-05-2008, 06:28 PM   #3 (permalink)
Junior Member

Join Date: Jan 2008
Location: Atlanta, GA
Posts: 12
Rep Power: 0 IVasilev is on a distinguished road

Blackbaud Products
- Raiser's Edge (RE)
- API/VBA

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
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote

Old 02-27-2008, 06:11 PM   #4 (permalink)
Junior Member

Join Date: Feb 2008
Location: Newcastle, Australia
Posts: 4
Rep Power: 0 TonyR is on a distinguished road

Blackbaud Products
- Raiser's Edge (RE)
- API/VBA

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.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote

Old 02-28-2008, 06:11 AM   #5 (permalink)
Likes to customize RE!

DavidZ's Avatar

Join Date: Jul 2006
Location: London, UK
Posts: 310
Rep Power: 3 DavidZ is on a distinguished road

Blackbaud Products
- Raiser's Edge (RE)
- API/VBA

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
__________________
David Zeidman
Zeidman Development
http://www.zeidman.info

Check out my RE API blog
http://www.re-decoded.com

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote

Old 02-28-2008, 06:46 AM   #6 (permalink)
Junior Member

Join Date: Jan 2008
Location: Atlanta, GA
Posts: 12
Rep Power: 0 IVasilev is on a distinguished road

Blackbaud Products
- Raiser's Edge (RE)
- API/VBA

Smile

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
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote

Old 02-28-2008, 09:09 PM   #7 (permalink)
Junior Member

Join Date: Feb 2008
Location: Newcastle, Australia
Posts: 4
Rep Power: 0 TonyR is on a distinguished road

Blackbaud Products
- Raiser's Edge (RE)
- API/VBA

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
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote

Old 03-01-2008, 07:16 AM   #8 (permalink)
Junior Member

Join Date: Jan 2008
Location: Atlanta, GA
Posts: 12
Rep Power: 0 IVasilev is on a distinguished road

Blackbaud Products
- Raiser's Edge (RE)
- API/VBA

I don't know if this information i shared(publishes) somewhere or somebody can share it:

2007 Conference for Nonprofits Raiser's Edge Advanced Sessions…in The Raiser’s Edge 7.82. This session will demonstrate how to use the CBatchAPI and CBatchFields object and explain the theories behind these classes. This is an advanced…2007 Conference for Nonprofits Raiser's Edge Advanced Sessions - 46.7K - Similar pages
__________________
Ivan Vasilev
Database Manager
USA, Atlanta, GA
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote

Old 03-03-2008, 04:58 PM   #9 (permalink)
Junior Member

Join Date: Jan 2008
Location: Atlanta, GA
Posts: 12
Rep Power: 0 IVasilev is on a distinguished road

Blackbaud Products
- Raiser's Edge (RE)
- API/VBA

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
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote

Old 03-04-2008, 10:56 PM   #10 (permalink)
Junior Member

Join Date: Feb 2008
Location: Newcastle, Australia
Posts: 4
Rep Power: 0 TonyR is on a distinguished road

Blackbaud Products
- Raiser's Edge (RE)
- API/VBA

that works well, thanks for all your help Ivan.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote

Old 03-06-2008, 09:47 AM   #11 (permalink)
Likes to customize RE!

DavidZ's Avatar

Join Date: Jul 2006
Location: London, UK
Posts: 310
Rep Power: 3 DavidZ is on a distinguished road

Blackbaud Products
- Raiser's Edge (RE)
- API/VBA

Nice solution Ivan!

David
__________________
David Zeidman
Zeidman Development
http://www.zeidman.info

Check out my RE API blog
http://www.re-decoded.com

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote

Old 07-09-2008, 06:30 PM   #12 (permalink)
jellyfish

Join Date: Jul 2008
Location: Marina
Posts: 3
Rep Power: 0 dnajd is on a distinguished road

Blackbaud Products
- Raiser's Edge (RE)

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
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote

Old 07-09-2008, 07:00 PM   #13 (permalink)
Junior Member

Join Date: Feb 2008
Location: Newcastle, Australia
Posts: 4
Rep Power: 0 TonyR is on a distinguished road

Blackbaud Products
- Raiser's Edge (RE)
- API/VBA

bbmoGIFT is in an enum called bbMetaObjects.

so your line of code would be:

.Fields(EBatchFieldFields.BatchField_fld_MetaObjectId) = bbMetaObjects.bbmoGIFT
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote

Old 07-10-2008, 08:16 AM   #14 (permalink)
Likes to customize RE!

DavidZ's Avatar

Join Date: Jul 2006
Location: London, UK
Posts: 310
Rep Power: 3 DavidZ is on a distinguished road

Blackbaud Products
- Raiser's Edge (RE)
- API/VBA

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
__________________
David Zeidman
Zeidman Development
http://www.zeidman.info

Check out my RE API blog
http://www.re-decoded.com

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote

Old 07-13-2008, 02:45 AM   #15 (permalink)
jellyfish

Join Date: Jul 2008
Location: Marina
Posts: 3
Rep Power: 0 dnajd is on a distinguished road

Blackbaud Products
- Raiser's Edge (RE)

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
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote

Old 07-14-2008, 05:59 AM   #16 (permalink)
Likes to customize RE!

DavidZ's Avatar

Join Date: Jul 2006
Location: London, UK
Posts: 310
Rep Power: 3 DavidZ is on a distinguished road

Blackbaud Products
- Raiser's Edge (RE)
- API/VBA