CTO Blog

We occasionally get requests from customers about doing batch updates to donor records. We have plans to address this within GiftWorks in the future but until then it has to be done manually. This is obviously not a great answer, but since GiftWorks has an API, developers have an additional option. Below is some VBScript that formats the addresses for all donors in an individual SmartList. Because this is an example, the only formatting I show is converting all text in an address to uppercase. There's no reason the script couldn't be extended to reach out to the postal service and validate the address. I'll leave that as an exercise for the reader.

**This script is provided only as an example and should be used with caution. It will modify data in your database. Running any scripts against your database should be done only after your database has been properly backed up. Also, scripts that modify your database should be done when nobody else is signed into it. There are mechanisms to protect multi-user access, but this script does not utilize them.

   1:  Const typeIndividual = 0
   2:   
   3:  ' create an instance of our application
   4:  Set App = CreateObject("MissionResearch.GiftWorks")
   5:   
   6:  ' Make sure the user is signed in so a db is selected
   7:  If App.Security.SignedIn Then 
   8:   
   9:      ' make sure the user is viewing a SmartList
  10:      If App.Shell.History.CurrentTask.Urlpath = "/list-browse-list" Then
  11:      
  12:          ' get a reference to the current SmartList based on the id passed to the page
  13:          Set smartlist = App.Modules.Donor.ListManager.GetList(App.Shell.QueryString("id"))
  14:          
  15:          ' make sure we have an Individual SmartList, or error out
  16:          If smartlist.ContentType = typeIndividual Then
  17:          
  18:              ' get a recordset based on the SmartList
  19:              Set rs = smartlist.ItemList.Recordset
  20:              
  21:              ' go thru each donor
  22:              Dim donor, address, changed
  23:              Do While Not rs.EOF
  24:                  changed = False
  25:                  Set donor = App.Modules.Donor.DonorManage.GetIndividual(rs("id"))
  26:                  ' go thru each address for this donor
  27:                  For Each address In donor.Addresses
  28:                      ' call the reformat method
  29:                      ' this example just uppercases all text
  30:                      changed = ReformatAddress(address)
  31:                      ' if the address was modified, 'changed' will be True
  32:                  Next
  33:                  ' if any address was changed, update the entire donor
  34:                  If changed Then
  35:                      App.Modules.Donor.DonorManage.UpdateIndividual donor
  36:                  End If
  37:                  rs.MoveNext
  38:              Loop
  39:              rs.Close
  40:          Else
  41:              App.Shell.MsgBox "Must be viewing an Individual SmartList"
  42:          End If
  43:      Else
  44:          App.Shell.MsgBox "Must be viewing a SmartList"
  45:      End If
  46:  Else 
  47:      App.Shell.MsgBox "You must be signed in before calling this script" 
  48:  End If
  49:   
  50:  ' this function just uppercases all text
  51:  ' return True if it needs changed
  52:  Function ReformatAddress(Address)
  53:      Address.Street1 = UCase(Address.Street1)
  54:      Address.Street2 = UCase(Address.Street2)
  55:      Address.City = UCase(Address.City)
  56:      Address.State = UCase(Address.State)
  57:      Address.Zip = UCase(Address.Zip)
  58:      Address.Country = UCase(Address.Country)
  59:      ReformatAddress = True
  60:  End Function
  61:   

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, but those that know how to use an object browser can check out the files: msdsvc.dll and gitwks.exe.


September 26 2006
Comments [1105]
Filed under:


I've seen a couple request from customers wanting the ability to keep some of their users out of certain areas in GiftWorks. Below is a small addin that attempts to solve that problem by removing the toolbar buttons at the top of the window. In this example I remove every application button except the Donors button (see the picture to the right).

See my HelloWorld post and my What's In A GiftWorks Addin post for more details on using the following addin file. This post will skim through the details and assume you've already created and used an addin file. 

   1:  <gml id="MissionResearch_DisableExample">
   2:      <info>
   3:          <title>Disable Addin Example</title>
   4:          <versions>
   5:              <version match="2.0.*.*" module="version2" />
   6:          </versions>
   7:      </info>
   8:      <module id="version2">
   9:          <objects>
  10:              <object id="MyObject" type="vbscript" url="" cache=""><![CDATA[
  11:                  Sub EventHandler(Ev)
  12:                      If Ev.Data.Url = "toolbar" Then
  13:                          For Each button In App.Shell.Toolbar.Buttons
  14:                              If button.Title <> "Donors" Then
  15:                                  App.Shell.Toolbar.Buttons.Remove button.Title
  16:                              End If
  17:                          Next
  18:                      End If
  19:                  End Sub
  20:              ]]></object>
  21:          </objects>
  22:          <handlers>
  23:              <handler id="module-execute" object="MyObject"/>
  24:          </handlers>
  25:      </module>
  26:  </gml>

 

toolbar buttons

The toolbar buttons at the top of GiftWorks are the main navigation elements for the application. GiftWorks inserts several by default and addins can modify those buttons or add their own. This post just concentrates on removing existing buttons. GiftWorks gives you access to these buttons through a Buttons collection.

App.Shell.Toolbar.Buttons

Each button has several properties that you can modify with code.

Button.Order - a number indicating the sort order the buttons should use for display
Button.Action - the action a button executes when clicked
Button.Title - the title of the button displayed
Button.ImageUp - the image file used when the button is in normal state
Button.ImageDown - the image file used when the button is in clicked state
Button.ImageOver - the image file used when the button has a mouse over it
Button.ImageDisabled - the image file used when the button is disabled

event handlers

You can embed event handlers in the addin file to handle events raised by GiftWorks. Event handlers are the primary means for addins to integrate with existing GiftWorks elements. This addin handles a general framework event called 'module-execute' which is fired whenever the framework needs to initialize the toolbar. GiftWorks fills the toolbar first with it's buttons then fires the event so addins can handle it as well. An addin can add toolbar buttons using a simpler interface which will be shown at a later time. This event enables an addin to modify buttons that have already been added. You could rename buttons or other things. This addin just checks for the Donors button and removes everything else. The <handler> element simply tells GiftWorks your addin wants to be called when the 'module-execute' event is raised. It then calls the EventHandler subroutine in the 'MyObject' script.

Try this our and let me know what you think. In later posts I will try to expose some more of the many GiftWorks events.


September 21 2006
Comments [6]
Filed under:


Updated 9/14/2006

Thanks to some helpful members of the IE7 compatibility team at Microsoft (specifically Keryn Mark), we were able to identify the reason GiftWorks was crashing. GiftWorks has code to keep IE from beeping every time a page changes which was causing the crash. I guess IE7 made some changes around calling the beeping function and our code was no longer valid--or most likely was never valid in the first place even though it worked. The good news is that we have a fix. The bad news is that it won't be available until the next update to GiftWorks which doesn't have a date yet. I will keep you posted.

 

For the past several months Microsoft has been beta testing a new release of Internet Explorer, version 7. As some of you may know, GiftWorks uses Internet Explorer internally for its user interface. Since the first IE7 beta, GiftWorks has not worked correctly and even crashes for some customers when they have the beta installed. We were hoping that the issue would have worked its way out by now, but Microsoft released their first release candidate (RC) of IE7 and the issue remains.

We are working with Microsoft to have this issue resolved for RC2, but you can actually help us raise the priority of this issue. For those that have installed IE7 beta, you were asked to join the beta program and provide feedback. Please sign in with your account at http://connect.microsoft.com and do a search for "GiftWorks". You should get at least one feedback item in the results. Please open that item and make sure it applies to what you're experiencing (typically a crash of GiftWorks), then submit a vote for the issue. Thanks and we'll keep you informed.


September 14 2006
Comments [0]
Filed under:


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

Flickr Show

Past Articles


Ads



Other Links