CTO Blog

November 23 2005

intro

What's really cool about GiftWorks is the ability to use Windows scripting to automate and add onto the application. GiftWorks is built on top of an application framework that enables this functionality very easily.This blog entry will be the first in a series that highlights the automation capabilities of GiftWorks and the underlying framework.

creating a donor

We'll use a simple script as an example. Below is the dialog steps for adding a new donor in GiftWorks...

That's how customers do it thru the UI. Below is the code to add a donor using VBScript. Please note that error checking has been ommited from this example to make it readable.

Const typeIndividual = 0

' Get an App reference to GiftWorks
Set App = CreateObject("MissionResearch.GiftWorks")

' Make sure the user is signed in so a db is selected
If
App.Security.SignedIn Then

    ' Create the donor using the Donor module
    Dim Donor, DonorId
    Set Donor = App.Modules.Donor.DonorManage.GetNewDonor(typeIndividual)
    With Donor
        .Fname = "Ben"
        .Lname = "Franklin"
        .Gender = "Male"
        .AddresseeFormal = "Mr. Ben Franklin"
        .AddresseeInformal = "Ben Franklin"
        .SalutationFormal = "Mr Franklin"
        .SalutationInformal = "Ben"
    End With

    ' add a primary address
    Dim Address
    Set Address = App.Modules.Donor.ContactManage.GetNewContact("address")
    Address.Primary = True
    Address.Order = 1
    Address.DisplayName = "Home Address"
    Address.Street1 = "71 East Liberty Street"
    Address.Street2 = ""
    Address.City = "Philadelphia"
    Address.State = 3
    Address.Zip = "19760"
    Donor.Addresses.Add Address

    ' Insert the donor
    DonorId = App.Modules.Donor.DonorManage.InsertIndividual(Donor)
    App.Shell.MsgBox "Donor was Added", "Success"

    ' Show the new donor in GiftWorks
    App.Shell.Navigate "graphite://donor/details-individual?id=" & Donorid
Else
    App.Shell.MsgBox "You must be signed in before calling this script"
End If

code breakdown

The first thing you do is get a reference to the GiftWorks Application object. You will use that reference to access everything within the program. The CreateObject call will actually start GiftWorks if it is not running, though this example script assumes GiftWorks has already been started and a user has signed in.

Once you have an App reference and have checked that the user is signed in, you use the Donor module to get a reference to a new Individual donor object. With that object you can set some properties and add an address contact. Once all the properties have been set, you need to insert the individual. Until you call the InsertIndividual() method, the donor doesn't exist in the database.

After the donor has been inserted, you can direct GiftWorks' UI to the actual details of the donor. And that's it.

up next

In the next segment I will show you what part of the code above is GiftWorks and what part of the code is provided by the framework. Feel free to leave comments.

« GiftWorks 2006 | Follow-up On Our First GiftWor... »
sweet. I see the navigation in the container is similiar to an http string; if I want my app browse to an external web page and show the page in the container, how do I do that? And what about launching a page outside the container, like you do on the current home page of GiftWorks?

(disclaimer--I'm a co-founder)
11/25/2005 4:12 PM UTC
You have a very keen eye for being the non-programming type :). As you pointed out, you can use any internet prototype for loading content into the main panel of the application (http, https, file, etc). graphite:// is a prototype that ships with the GRAPHITE application framework. It is similar to a http url but the framework applies some extra processing to the content before loading it (like task tracking, help loading, etc).

As far as loading external windows, there is special programming call for that which I will share in upcoming posts. It's not difficult, but needs some explanation.
11/29/2005 3:36 AM UTC
Name
E-mail
Home page

Comment (HTML not allowed)  

Want More? Try browsing our other Mission Research developer blogs...
Steve Fafel, Mike Greineder, Jonny Leaman

Search


Article Tags


Other Mission Blogs


Past Articles


Ads



Other Links