It has been years since I coded on a regular basis, and I wish I had more time to spend on it now. I am making progress with using the IOM API by stealing code examples and re-purposing them. However, I have not found a guide to the basic rules of how/when to call and release fields. Is it possible to use code in the API to manipulate the value of a Virtual Field?
Here is what I am trying to do:
In my data file, I have a field that tells me the '# of children in a household' (Field "P" in the code example below). I want to combine that data with the 'Membership Level' (also in the data file) to calculate the 'Admit #'. 'Admit #' is not in the data file, but I created it as a Virtual Field (it is a Constituent Attribute Description in Raiser's Edge).
Here is the code:
Public Overrides Sub BeforeConstituentSave(ByVal oRec As Blackbaud.PIA.RE7.BBREAPI.CRecord, _
Cancel As ImportOM.API.iCancel)
If Import.Fields.GetByName("Membership Level").Value = "Individual Basic" Then Import.Fields.GetByName("Admit #").Value = 2 Else
If Import.Fields.GetByName("Membership Level").Value = "Individual Premium" Then Import.Fields.GetByName("Admit #").Value = 3 Else
If Import.Fields.GetByName("Membership Level").Value = "Household" Then Import.Fields.GetByName("Admit #").Value = 3 + Import.Fields.GetByExcelName("P").Value Else
If Import.Fields.GetByName("Membership Level").Value = "Household Premium" Then Import.Fields.GetByName("Admit #").Value = 4 + Import.Fields.GetByExcelName("P").Value
'Calculates Value for Constituent Attribute "Admit #" based on "Membership Category" & Value of "# Children Under 18 Living at Home".
The logic makes sense, but I get an error of "Object reference not set to an instance of an object." So, that tells me that I am not properly addressing the 'Admit #' field. Right?
Any help/clues/suggestions that you can provide will be much appreciated!
Thanks for the tip on the Add Virtual Column button - using that function cleared up my errors.
I already have a Dictionary applied to the 'Membership Level' field to convert a user friendly string to the exact text string that I need to match values in Raiser's Edge. The "# of children in the household" comes in as a number. I guess I can build a 2nd dictionary for the 'Membership Level' field that translates the name of the level into a numerical value representing the base admit value (that the '# of children...' is then added to). I wonder if I can apply that new dictionary to the "Admit" virtual field (and change my code from a ".Value =" to a ".Value.replace"), or if I need to create another virtual field for 'Admit base'? Hmm, I'll try that tomorrow.
(If Forum Protocol dictates that I shouldn't be thinking 'out-loud' here, someone please tell me, so I don't alienate the crowd.)
Thanks again for your quick response - it has been helpful, and given me a new direction to explore.
As Wayne mentioned (thanks for the contributions to the forum Wayne!), Jim and Patrick from the Omatic Product Development team put together an introductory video to the ImportOmatic API here: http://vimeo.com/omaticsoftware/rev...f81a4fed29
As for your question about "Forum Protocol", please contribute or ask anything that you like. The community of people taking advantage of the IOM API is pretty small, but every post with a question or idea or musing about it helps it grow. I think very few people are aware of this powerful engine sitting there in ImportOmatic just waiting to do their drudgery! :)