Automate adding of students into a Parents Gateway Group from a csv file
- You would need to prepare a csv file with all the full names of the students beforehand. The names must match the names in the system, i.e. from Cockpit.
- Create a PG Group using Chrome
- Click on “+ Add Students”
- As the table of results is “lazy loaded”, you will need to scroll down to the bottom of the table to load the entire list of students from the system beforehand.
- Right-click on the Chrome browser and select “Inspect”
- Click on the “Console” tab.
- Paste this code into the box in the Console tab and press the Enter key.
async function loadCSV(file) {
let text = await file.text();
return text.split("\n").map(name => name.trim()).filter(name => name);
}
function findRowByName(name) {
for (let row of document.querySelectorAll(".StudentTableItem__Container-sc-xspry6-0")) {
let studentName = row.querySelector(".student-name-text")?.textContent.trim();
if (studentName?.toLowerCase() === name.toLowerCase()) return row;
}
return null;
}
async function runRPA(namesList) {
for (const name of namesList) {
console.log(`🔍 Searching for: ${name}`);
await new Promise(resolve => setTimeout(resolve, 2000)); // Wait for UI update
let row = findRowByName(name);
let checkbox = row?.querySelector(".checkbox");
if (checkbox) {
console.log(`✅ Selecting: ${name}`);
checkbox.click();
} else {
console.warn(`⚠️ Not found: ${name}`);
}
await new Promise(resolve => setTimeout(resolve, 1000)); // Pause before next name
}
console.log("🎉 RPA task completed!");
}
function promptCSVUpload() {
let input = Object.assign(document.createElement("input"), { type: "file", accept: ".csv" });
input.addEventListener("change", async e => {
let namesList = await loadCSV(e.target.files[0]);
console.log("📂 CSV Loaded. Starting RPA...");
runRPA(namesList);
});
input.click();
}
promptCSVUpload();