Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Kartra Bulk Helpdesk Ticket Updater (Use With Care!)
- // Select tickets to update via filtering, then paste the function below
- // and "updateAllTickets();" (without the double-quotes) into the console
- // (Command + Option + J (Mac) or Control + Shift + J (PC)).
- function updateAllTickets () {
- let status;
- const tickets = [];
- const updateNext = () => {
- if (!tickets.length) {
- alert('All tickets updated. Page will now reload.');
- location.reload();
- } else {
- const id = tickets.shift();
- console.log('Updating ticket ' + id);
- $.post(action_route + '/change_status/', { ticket_id: id, action: status }).done(() => setTimeout(updateNext, 500));
- }
- };
- $('.js_ticket_li').each((ind, el) => tickets.push(el.id.replace(/ticket_/, '')));
- if (tickets.length) status = prompt(`Enter read, unread, pending, or closed to update ${tickets.length} ticket(s):`);
- if (['read', 'unread', 'pending', 'closed'].includes(status)) updateNext();
- else alert('No changes made');
- }
Advertisement