Skip to content
This repository was archived by the owner on Nov 10, 2020. It is now read-only.
This repository was archived by the owner on Nov 10, 2020. It is now read-only.

Trying to Add TrackingCategory Value to Invoice Line C# #75

Description

@QueenBee61

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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions