I am trying to add values to a JSON object to post an invoice in the Xero API. When I do it with simple text values it works fine and when I used input values it also works fine, but if I try and combine the two, like
invObj.InvoiceNumber = "INV-" + document.getElementById("orderId").value;
It fails to create an invoice. Is there a way to join a string and input value so that it will be accepted by the api.
The Json is created in the renderer process of an electron app and passed to the main process where the api call is made within an express app.
var invObj = {};
invObj.Type = "ACCREC";
invObj.Contact = {};
invObj.Contact.Name = document.getElementById("customerName").value;
invObj.Contact.EmailAddress = document.getElementsByClassName("bill-address-input")[0].value;
invObj.Contact.FirstName = document.getElementsByClassName("bill-fname-input")[0].value;
invObj.Contact.LastName = document.getElementsByClassName("bill-lname-input")[0].value;
invObj.InvoiceNumber = "INV-" + document.getElementById("orderId").value; //fails
invObj.InvoiceNumber = "INV-WS2222"; //succeeds
invObj.InvoiceNumber = document.getElementById("orderId").value; //succeeds
invObj.DateString = "2009-05-27T00:00:00";
invObj.DueDateString = "2009-06-06T00:00:00";
invObj.LineAmountTypes = "Exclusive";
invObj.LineItems = [
];
invObj.LineItems[0] = {};
invObj.LineItems[0].Description = "Services as agreed";
invObj.LineItems[0].Quantity = "4";
invObj.LineItems[0].UnitAmount = "100";
invObj.LineItems[0].AccountCode = "201";
This is the api call
let oauth_verifier = req.query.oauth_verifier;
let accessToken = await xeroClient.oauth1Client.swapRequestTokenforAccessToken(lastRequestToken, oauth_verifier)
.then(async() => {
var invoice = await xeroClient.invoices.create(data)
.then((invoice) => {.....