Autofill Tracking Category Xero – JavaScript

Recently I was helping out in an office where we needed to add the same tracking category against purchases that were being entered into Xero.

Currently there is no option for Autofilling the field in Xero so I took to tampermonkey and wrote a small script that will autofill the option each time a purchase is opened.

// @name         Xero Autofill
// @namespace    http://twitter.com/insttechno
// @version      0.1
// @description  Autofill Tracking Category In Xero
// @author       You
// @match        https://go.xero.com/AccountsPayable/*
// @grant        none
// ==/UserScript==


//window event listener needed to wait for all elements to load
window.addEventListener('load', function() {
    //Grab and Click Tracking Option 2
document.getElementsByClassName("x-grid3-cell-inner x-grid3-col-colTracking2 x-unselectable")[0].click();
    //Set Variable "track" to be the empty text box
var track=document.getElementById("ext-comp-1013");
    //Fill that box with some text
track.value="Text Goes Here";
}, false);

If you install the chrome extension Tampermonkey and add it as a userscript Рeach time you go to Accounts Payable and open a purchase it should autofill the tracking category.

I used the elements in the code for Tracking Option 2 but it should only be small changes that are needed to fill a different option.

Please be aware that this script is quite likely to break if Xero change their backend code between releases.




Leave a Reply

Your email address will not be published. Required fields are marked *