Start a new topic

Splitting a field into X attributes

Hi all,

I'm working with a data file that has a field containing slash-delimited ticked numbers. (e.g. "001/002/003/004/009")

What I'd like to do is create an action with an attribute for each of these ticket numbers. My instinct says the best way would be to split the string and iterate over the numbers, creating an attribute for each. Trouble is, I'm not sure how I'd go about that last part. How can I programmatically add an attribute to an action?

Keen to hear any interesting suggestions!


Adding an attribute to an action is fairly straightforward

With oAction.Attributes.Add() 
    .Fields(Blackbaud.PIA.RE7.BBREAPI.EattributeFields.Attribute_fld_ATTRIBUTETYPES_ID) = [Attribute Category ID]
    .Fields(Blackbaud.PIA.RE7.BBREAPI.EattributeFields.Attribute_fld_VALUE) = [Attribute Description]
    .Fields(Blackbaud.PIA.RE7.BBREAPI.EattributeFields.Attribute_fld_ATTRIBUTEDATE) = [Attribute Date]

End With 

The hard part is getting the action object that you want.

If you are adding a new action each time then it is easier since you can create the new action first then you already have the object and you can add the attribute as above.

If you are adding on to an existing action (or creating the action through the IOM profile) then you have to iterate through the actions on the record to find the right object using some criteria like action type/date added/added by etc. and use that object.

Thanks Wayne - that does look pretty straightforward.

Luckily we'll be adding either 0 or 1 actions per row, each with 1 or more attributes - I agree it would be harder to try to attach onto pre-existing actions.
Spoke too soon... Can't seem to work out how to add an action to a constituent in the API.

I'm working in AfterConstituentOpen (so oRec is already initialised), but oRec.Actions doesn't seem to have an Add method. Any clues?
Hmm, I haven't run into this yet. I am really not sure.

All indications point to you creating a new CAction object and calling Init on it with the current session context.

How you actually link it to the oRec is a bit of a mystery though I must admit. The only example in the help files shows creating a new Notepad using a form which doesn't really explain much.

You could use IOM to make the action and then "find" the action again in BeforeConstituentSave by iterating through the actions on the record and picking up the one that was just added.
Wayne is correct. You would need to create a new CAction object, set its Constituent property and save. However, this will not add the action to the Actions collection on the oRec object. The oRec object would have to be reloaded in order to see it in the collection.
Login or Signup to post a comment