Follow

GiftWorks API

We have been asked about an API for GiftWorks and while we don't have a published API or documentation, there is some that you can do with GiftWorks using programming tools. These samples were designed for GiftWorks 2013, but will work for newer versions.

Here is a sample of how to add a donor using VBScript: ** These scripts are provided only as examples and should be used with caution. It will modify data in your GiftWorks database. Running any scripts against your GiftWorks database should be done only after your GiftWorks database has been properly backed up. Also, scripts that modify your database should be done when nobody else issigned into it. There are mechanisms to protect multi-user access, but this script does not utilize them.

'***************************************************************************
' Profile Types
'***************************************************************************
Const profiletypes_typeDonor = 0
Const profiletypes_typeOrganization = 1
Const profiletypes_typeHousehold = 3

' create an instance of GiftWorks
Set App = CreateObject("MissionResearch.GiftWorks.7")

' Make sure the user is signed in to GiftWorks
If App.Security.SignedIn Then  

    Dim donor
    Dim display, fname, lname, prefix, companyname
    Dim salutationFormal, salutationInformal
    Dim addresseeFormal, addresseeInformal

    fname = "API"
    lname = "TEST"

    ' add donor
    Set donor = App.Modules.Donor.DonorManage.GetNewDonor()
    donor.profile = profiletypes_typeDonor
    donor.display = display
    donor.title = prefix
    donor.fname = fname
    donor.lname = lname
    donor.companyname = companyname
    donor.salutationFormal = salutationFormal
    donor.salutationInformal = salutationInformal
    donor.addresseeFormal = addresseeFormal
    donor.addresseeInformal = addresseeInformal

    Dim address, street, city, stateId, zip

    street1 = "100 Main Street"
    city = "Lancaster"

    ' create and add an address
    Set address = App.Modules.Donor.ContactManage.GetNewContact("address")
    address.street1 = street1
    address.city = city
    address.State = stateId ' from the donor_list_states table
    address.zip = zip    
    donor.Addresses.Add address, retId
    address.Id = retId

    ' set the donor primary address
    donor.FKPrimary = address.Id

    ' clear variable
    retId = 0

    Dim email, emailaddress

    emailaddress = "email@test.com"

    ' create and add an email address
    Set email = App.Modules.Donor.ContactManage.GetNewContact("email")
    email.displayName = "Email"                        
    email.address = emailaddress
    donor.EmailAddresses.Add email, retId
    email.Id = retId

    ' set the primary email address for the donor
    donor.FKEmail = email.Id

    ' clear variable
    retId = 0

    Dim phone, phonenumber

    phonenumber = "(717) 555-1212"

    Set phone = App.Modules.Donor.ContactManage.GetNewContact("phone")
    phone.displayName = "Phone"                        
    phone.number = phonenumber
    donor.Phones.Add phone, retId
    phone.Id = retId

    ' set primary phone number for the donor
    donor.FKPhone = phone.Id

    If App.Modules.Donor.DonorManage.UpdateDonor(donor) Then
        Msgbox "Donor Added"
    Else
        ' something went wrong
    End If
Else
    Msgbox "You must sign in to GiftWorks to run this script"
End If

Here is a sample of how to work with one-time donations using VBScript: (Note: GiftWorks does not currently have an API for working with pledges)

' create an instance of GiftWorks
Set App = CreateObject("MissionResearch.GiftWorks.7")

' Make sure the user is signed in to GiftWorks
If App.Security.SignedIn Then

    ' define variables
    Dim oDonation
    Dim oSearch 
    Dim oDonations 

    ' add a new single-fund donation for donor id 1
    Set oDonation = App.Modules.Donation.Donations.GetNewDonation(1)
    oDonation.Solicitor = "Joe Solicitor"
    oDonation.FKAppeal = 2
    oDonation.FKFund = 1003
    oDonation.FKCampaign = 4
    oDonation.PaymentType = 2
    oDonation.DonationDate = "6/29/2012"
    oDonation.DonationAmount = 250.00
    oDonation.ReceiptedAmount = 250.00
    oDonation.CheckNumber = "12345"
    oDonation.CheckDate = "6/27/2012"

    If App.Modules.Donation.Donations.UpdateDonation(oDonation, False) Then
        Msgbox "Donation Added"
    Else
        ' something went wrong
    End If    

    ' add a new split-fund donation for donor id 1
    Set oDonation = App.Modules.Donation.Donations.GetNewDonation(1)
    oDonation.Solicitor = "Joe Solicitor"
    oDonation.FKAppeal = 2
    oDonation.FKCampaign = 4
    oDonation.PaymentType = 2
    oDonation.DonationDate = "6/29/2012"
    oDonation.AddFund 1003, 75.00 
    oDonation.AddFund 1, 25.00
    oDonation.ReceiptedAmount = 100.00    
    oDonation.CheckNumber = "12345"
    oDonation.CheckDate = "6/27/2012"

    If App.Modules.Donation.Donations.UpdateDonation(oDonation, False) Then
        Msgbox "Donation Added"
    Else
        ' something went wrong
    End If

    ' update existing one-time donation id 350
    Set oDonation = App.Modules.Donation.Donations.GetDonation(350) 
    oDonation.DonationDate = "11/28/11" 
    oDonation.Directed = True 
    oDonation.DirectedPurpose = "Building Project" 
    oDonation.PaymentType = 7 
    oDonation.RemoveAllFunds 
    oDonation.AddFund 1003, 135.00 
    oDonation.AddFund 1, 35.00

    If App.Modules.Donation.Donations.UpdateDonation(oDonation, False) Then
        Msgbox "Donation Updated"
    Else
        ' something went wrong
    End If

   ' logical delete of one-time donation id 350
    If App.Modules.Donation.Donations.DeleteDonationById(350, 0, False) Then
        Msgbox "Donation Logically Deleted"
    Else
        ' something went wrong
    End If

   ' permanent delete of one-time donation id 350
    If App.Modules.Donation.Donations.DeleteDonationById(350, 1, False) Then
        Msgbox "Donation Permanently Deleted"
    Else
        ' something went wrong
    End If

    ' get all one-time donations for a campaign id 5
    Set oSearch = App.Modules.Donation.Donations.GetNewDonationCriteria() 
    oSearch.FKCampaign = 5 
    Set oDonations = App.Modules.Donation.Donations.GetDonationsBySearch(oSearch, True)

    ' get all one-time donations for fund 1 and update them to fund 1003 
    Set oSearch = App.Modules.Donation.Donations.GetNewDonationCriteria() 
    oSearch.FKFund = 1 
    Set oDonations = App.Modules.Donation.Donations.GetDonationsBySearch(oSearch, True) 
    For Each oDonation In oDonations 
       oDonation.FKFund = 1003 
    Next 
    App.Modules.Donation.Donations.UpdateDonations oDonations, False
Else
    Msgbox "You must sign in to GiftWorks to run this script"
End If

We have not released a GiftWorks SDK yet so there is no documentation available to show you the rest of the properties for a donor or donation, but those that know how to use an object browser can check out the files: donors.dll, donations.dll and giftwks.exe.

Was this article helpful?
0 out of 0 found this helpful
Have more questions? Submit a request

Comments

Powered by Zendesk