One issue that I frequency encounter was raised as a post on the forum for a similar problem:
When you create a gift you need to add a fund, campaign and appeal. The problem is that the values on the gifts are dependant on the user options of the person running the code. When I first encountered this problem I was amazed that this could have been programmed in this way.
For example if I am running the code and I usually view fund descriptions rather than IDs the following code will work fine:
Code:
Public Sub addGift(oConstit As CRecord)Dim oGift As New CGift oGift.Init SessionContext oGift.Fields(GIFT_fld_Constit_ID) = oConstit.Fields(RECORDS_fld_ID) oGift.Fields(GIFT_fld_Amount) = 10 oGift.Fields(GIFT_fld_Fund) = "General Fund" oGift.Save oGift.CloseDown Set oGift = Nothing End Sub
However if I usually view my funds as ID then this will fail as there is no fund ID called ‘General Fund’ (only a description).
What I need to do is to either ensure everyone in the organisation has the same user options (this I think is not a very robust coding solution) or alternatively add some code to check whether the user uses the id or the description for funds.
Code:
Dim oReServices As reservices Dim sFund As StringSet oReServices = New reservices oReServices.Init getSessionContext If oReServices.GetUserPref(USER_fld_FUNDFORMAT) = "Description" Then sFund = "General Fund" Else sFund = "112233" End If '------ Code continues ------
That way you know if your user is using a description or id and you can add the correct fund value.