List Solutions
This script gets a list of solutions in the current workspace and displays them in a table.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Solutions Table</title>
<style>
body {
font-family: Arial, sans-serif;
margin: 20px;
}
table {
width: 100%;
border-collapse: collapse;
margin-top: 20px;
}
th,
td {
padding: 10px;
text-align: left;
border: 1px solid #ddd;
}
th {
background-color: #f4f4f4;
}
tr:nth-child(even) {
background-color: #f9f9f9;
}
tr:hover {
background-color: #f1f1f1;
}
.container {
max-width: 900px;
margin: 0 auto;
}
.header {
text-align: center;
margin-bottom: 20px;
}
</style>
</head>
<body>
<div class="container">
<h1 class="header">All Solutions</h1>
<table id="solutionsTable">
<thead>
<tr>
<th>Name</th>
<th>Applications Count</th>
<th>Automation Count</th>
<th>Records Count</th>
<th>Created Date</th>
</tr>
</thead>
<tbody>
<!-- Data will be populated here by the script -->
</tbody>
</table>
</div>
<script>
// Fetch solutions from SmartSuite API and populate the table
window.SmartSuite.list_solutions().then((res) => {
// Sort solutions alphabetically by name
res.sort((a, b) => a.name.localeCompare(b.name));
// Get reference to the table body where solutions will be displayed
const tableBody = document.querySelector("#solutionsTable tbody");
// Iterate through each solution and create table rows
res.forEach(solution => {
// Format the creation date to local US date string (MM/DD/YYYY)
const formattedDate = new Date(solution.created).toLocaleDateString("en-US");
// Create HTML for a new table row with solution data
const row = `
<tr>
<td>${solution.name}</td> <!-- Solution name -->
<td>${solution.applications_count}</td> <!-- Number of applications -->
<td>${solution.automation_count}</td> <!-- Number of automations -->
<td>${solution.records_count}</td> <!-- Number of records -->
<td>${formattedDate}</td> <!-- Creation date -->
</tr>
`;
// Insert the new row at the end of the table
tableBody.insertAdjacentHTML('beforeend', row);
});
}).catch(err => {
// Log any errors that occur during the API call
console.error("Error fetching solutions:", err);
});
</script>
</body>
</html>