I am attempting to create new invoices in QuickBooks using the V3 API. I have the invoice creation working perfectly, except I cannot set the values for the 3 custom fields.
I need a VB or C# resolution that utilizes the AnyIntuitObject property in this context.
Here is the code that I am attempting to implement:
Dim serviceContext As ServiceContext = getServiceContext(profile)
Dim invoiceDataService As New DataService(serviceContext)
Dim oInvoice As New Invoice()
oInvoice.DocNumber = "8675309"
oInvoice.TxnDate = DateTime.Today.Date
oInvoice.TxnDateSpecified = True
oInvoice.CustomerRef = New ReferenceType() With {.Value = "1885", .name = "QBT"}
Dim cField As New CustomField()
cField.DefinitionId = 1
cField.Name = "MyCustomFieldName"
cField.Type = CustomFieldTypeEnum.StringType
cField.AnyIntuitObject = New String() {"MyCustomFieldValue"}
oInvoice.CustomField = New CustomField() {cField}
Dim invLine As New Line()
invLine.Amount = 999.99D
invLine.AmountSpecified = True
invLine.DetailType = LineDetailTypeEnum.SalesItemLineDetail
invLine.DetailTypeSpecified = True
invLine.AnyIntuitObject = New SalesItemLineDetail With
{
.ItemElementName = ItemChoiceType.UnitPrice,
.AnyIntuitObject = 999.99D,
.Qty = 1D,
.ItemRef = New ReferenceType() With {.name = "Service", .Value = "529"}
}
oInvoice.Line = New Line() {invLine}
Dim invoiceAdded As Invoice = invoiceDataService.Add(Of Invoice)(oInvoice)
I have reviewed every thread I can find pertaining to custom fields and the API and still have not found a resolution.
Any help that can be provided would be greatly appreciated!
Resolved the issue by using the following:
Dim customFieldList As New List(Of CustomField)
Dim cField As New CustomField()
cField.DefinitionId = 2
cField.Name = "Week ending"
cField.Type = CustomFieldTypeEnum.StringType
cField.AnyIntuitObject = inv.WeekEnding.ToString("MM/dd/yyyy")
customFieldList.Add(cField)
oInvoice.CustomField = customFieldList.ToArray