XeroAPI.Net icon indicating copy to clipboard operation
XeroAPI.Net copied to clipboard

Trying to Add TrackingCategory Value to Invoice Line C#

Open QueenBee61 opened this issue 5 years ago • 0 comments

I am trying to add TrackingCategory value to invoice line and I receive an error "Object reference not set to an instance of an object).

` LineItem li = new LineItem(); li.LineAmount = inv.LineItems[i].LineAmount; li.ItemCode = inv.LineItems[i].ItemCode; li.Description = inv.LineItems[i].Description; li.AccountCode = inv.LineItems[i].AccountCode; li.UnitAmount = inv.LineItems[i].UnitAmount; var categories = inv.Categories.Where(c => c.TicketChargeLineId == inv.LineItems[i].TicketChargeLineId); foreach(var c in categories) { if(c.Value != "") { li.Tracking = new ItemTracking();

                            ItemTrackingCategory tc = new ItemTrackingCategory();
                            tc.Name = c.Name;
                            tc.Id = c.Id;
                            tc.Option = c.Value;
                            li.Tracking.Add(tc);
                          
                        }

                    }
                    
					lineItems.Add(li);

` It seems to work but when I look at the invoices in Xero, the Tracking Category fields are blank.

QueenBee61 avatar Nov 20 '19 19:11 QueenBee61