Start a new topic

Update Job Assignment Records

Hello,

I am planning to develop a profile for updating job assignment records. What I am not clear about is how to load an assignment record using either System ID or Import ID. Since job assignments do not have a loadbyfield method, there must be another way. I think I could use the Item Method and pass IOM the System ID for each assignment? Has anyone used the API to access job assignments?


Thanks, Grant




I originally tried this, but it did not work.


Sub updateJobAssignment()

Dim oJob As New CJob
Dim ojAssign As CJobAssignment
   
   
    'Set ojob = CJob
    oJob.Init REApplication.SessionContext
   
    oJob.LoadByField uf_JOB_IMPORT_ID, "00170-557-0000000008"

    

    For Each ojAssign In oJob.Assignments
        'Debug.Print ojAssign.Fields(JobAssignment_fld_DEPARTMENT)
        If "" & ojAssign.Fields(JobAssignment_fld_DEPARTMENT) = "Business Support" And _
            "" & ojAssign.Fields(JobAssignment_fld_END_DATE) = "" Then
           
            ojAssign.Fields(JobAssignment_fld_NOTES) = "dsfd"
            
        End If
    Next
    
    oJob.Closedown
    Set Object = Nothing

End Sub


Then I checked out Blackbaud knowledgebase BB703331  How to write code to edit a job assignment

which had sample code. This works inside RE as the host. to make it work with IOM, you'll need to change

 oRec.Init REApplication.SessionContext     to      oRec.Init(import.SessionContext)


essentially you load  up the Constituent, then look through all Constituent's JobAssignments (maybe you want to compare with JobAssignmentID to be 100% sure), then edit the fields you want to edit

the code is in VBA, so you'll need to tidy up for .net of IOM.


Sub editJob()



 Dim oJob As CJob

    Dim oJA As CJobAssignment

   

    Dim oVol As CVolunteer

    

    Dim oRec As CRecord

    Set oRec = New CRecord

    oRec.Init REApplication.SessionContext

    oRec.Load 1830449


    Set oVol = oRec.Volunteer

    

'    Set oJAs = oVol.Assignments

    

    For Each oJA In oVol.Assignments

        If "" & oJA.Fields(JobAssignment_fld_DEPARTMENT) = "Business Support" And _

            "" & oJA.Fields(JobAssignment_fld_END_DATE) = "" Then

            oJA.Fields(JobAssignment_fld_NOTES) = "Testing, 1, 2, 3"

            oRec.Save

        Else: End If

    Next oJA

    

    Set oJA = Nothing


    oRec.Closedown

    Set oRec = Nothing



End Sub




Hi Chinh Quan,

Our next release of IOM due for release early next month has a TON of improvements and additions for volunteer functionality (we think it's pretty much anything anyone could ask for). If you'd like a beta version to see what is coming we can arrange that for you.


Thanks very much for contributing to the IOM API forum!!

Jeff

Login or Signup to post a comment