Need a little help here.
I just want to add a Group Item with Item List on it using the QBFC12 but am having a trouble with it. I have tried creating the same method like this with Inventory Assembly and it works well. but this one makes me feel terrible. When the request is processed, it return error telling that there're missing fields on the request. Hope anyone can help me out with this.
Thanks
Here's my code below:
Dim msgSetRequest As IMsgSetRequest
Dim QBSM As New QBSessionManager
Try
With QBSM
.OpenConnection("", "QB Test")
.BeginSession("", ENOpenMode.omDontCare)
End With
Catch ex As Exception
Throw New Exception(ex.Message)
Return False
End Try
msgSetRequest = QBSM.CreateMsgSetRequest("US", 8, 0)
msgSetRequest.Attributes.OnError = ENRqOnError.roeStop
msgSetRequest.ClearRequests()
Dim gAdd As IItemGroupAdd = msgSetRequest.AppendItemGroupAddRq
gAdd.IsActive.SetValue(True)
gAdd.Name.SetValue("Group Name")
gAdd.ItemDesc.SetValue("Group Description")
For Each gListItem As clsInventoryGroupItem In gItem.InventoryGroupItemList
Dim gItemAdd As IItemGroupLine = msgSetRequest.AppendItemGroupAddRq.ItemGroupLineList.Append
gItemAdd.ItemRef.FullName.SetValue(gListItem.ItemRef)
gItemAdd.Quantity.SetValue(gListItem.Quantity)
Next
Dim response As IMsgSetResponse = QBSM.DoRequests(msgSetRequest)
If response.ResponseList.GetAt(0).StatusCode = 0 Then
MessageBox.Show("Success")
else
MessageBox.Show("An Error occurred while inserting Group")
endif
I think the problem is how you are adding your group lines, but haven't tested it yet. Instead of using ItemGroupLineList.Append from the msgSetRequest, you should call it from your IItemGroupAdd object, gAdd. Here's what I came up with, but didn't test it.