Updating IDO’s via VB Code


This example continues from the post Filtering Via VB.NET . You may want to read that post first before reading this, as it will put what I am doing into context.

In this example we are setting all jobs that are currently in a firm stat to released if they match a certain criteria (which is dealt with on the IDO, which is based on a view)

The Code
Sub PBTI_ReleaseJob()

For n AsInteger = 0 To ThisForm.PrimaryIDOCollection.GetNumEntries – 1

‘For n As Integer = 0 To 1 ‘Limits to first record only

Dim r AsIWSIDORow = ThisForm.PrimaryIDOCollection.Item(n)

Application.ShowMessage(“Row : “ & CStr(n) & “:” & r(“ChangeIntermediate”).Value & ” : “ & r(“item”).Value & ” : “ & r(“job”).Value)

‘For Debug Purposes

Dim JobResponse AsLoadCollectionResponseData

Dim sJobNum AsString

Dim sFilter AsString

sJobNum = r(“job”).Value

sFilter =“Job = ‘” & sJobNum & “‘”

JobResponse = Me.IDOClient.LoadCollection( _

“SLJobs”, _

“Job, Stat”, _

sFilter, _

“”, -1)

MsgBox(JobResponse.Items.Count)

If JobResponse.Items.Count > 0 Then

Dim updateRequest AsUpdateCollectionRequestData

Dim updateItem AsIDOUpdateItem

‘ create a new UpdateCollection request

updateRequest =

NewUpdateCollectionRequestData(“SLJobs”)

‘ create a new update item for the row we loaded

updateItem =

NewIDOUpdateItem(UpdateAction.Update, JobResponse.Items(0).ItemID)

‘ add CustNum property from LoadResposne, not modified

updateItem.Properties.Add(

“Job”, JobResponse(0, “Job”).Value, False)

‘ add Charfld1 property using a new value, modified

updateItem.Properties.Add(

“Stat”, “R”, True)

‘ add the update item to update request

updateRequest.Items.Add(updateItem)

‘ save changes

Me.IDOClient.UpdateCollection(updateRequest)

EndIf

Next

EndSub

Leave a comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.