Retrieve URL of all Knack Apps
If you need a list of knack applications, you can retrieve them from the console when signed into the builder.
Original Code: https://gist.github.com/ktaranov/41f32478f701d8cdb598efbbf70e379e
Steps to retrieve all URLs of Knack applications
Sign-In to Knack dashboard
Go to https://dashboard.knack.com/
If you are signed in as the Transportation Data service account, it will retrieve all knack applications including test applications and sandbox.
If you are signed-in as a builder, it will show all applications that are shared to you.
Copy/Paste the code below into the console
Right-click web page - > Inspect
Navigate to Console tab - > Copy/Paste JS code below using the "Copy" button on top right corner of code block and press Enter
NOTE: If a warning shows up you may have to write
allow pasting
if the browser console will not let you.
Highlight the entire table in the console and right click > Copy
From there, the index, Application Name, and URL will be saved on your clipboard and you can put it in a spreadsheet or note document.
Optional: Format URL links in Excel
When you post your clipboard to an Excel document, the URLs will be wrapped in single quotes. You can make them functional hyperlink in excel using this excel formula below.
=HYPERLINK(SUBSTITUTE(D2,"'",""),"Builder")
=HYPERLINK(SUBSTITUTE(E2,"'",""),"Live App")
It should look something like this:
JavaScript
There are two types of URLs you can retrieve with this code, the builder URL or the URL home page. You may select either one of the tabs based on your preference.
Live App URL: Retrieves URL that starts with
https://atd.knack.com/
Builder URL: Retrieves URL that starts with
https://builder.knack.com/atd/
Both + Records: Retrieve App Name, total # of records, Builder URL, and Live app URL
This is the most up to date
let x = document.querySelectorAll("a");
let builderLink = "https://builder.knack.com/atd/";
let knackLink = "https://atd.knack.com/";
let myarray = [];
for (let i = 0; i < x.length; i++) {
let nametext = x[i].textContent;
let cleantext = nametext.replace(/\s+/g, " ").trim();
let cleanlink = x[i].href;
if (cleanlink.includes(builderLink) && cleantext.length > 0) {
// Replaces Builder URL with Home Page URL
cleanlink = cleanlink.replace(builderLink, knackLink)
myarray.push([cleantext, cleanlink]);
}
}
console.table(myarray);
Last updated
Was this helpful?