Purpose
Retrieve the authenticated supplier account's orders from the last 30 days as CSV without interacting with the export form.
When to Use
Use when the caller needs a CSV export of recent ALM Connect supplier orders. The browser must already have an authenticated ALM Connect session.
Workflow
- Navigate directly to
https://almconnect.com.au/suppliers/my-account/orders?page=0&pageSize=100. - In one page evaluation, read the CSRF token from
#exportOrderForm input[name="CSRFToken"]and fetch the same-origin export endpoint with the 30-day order filter:
(async () => {
const tokenInput = document.querySelector(
'#exportOrderForm input[name="CSRFToken"]',
);
const token = tokenInput?.value;
if (!token) return { ok: false, error: "NO_TOKEN_FOUND", csv: null };
const params = new URLSearchParams({
ordersCode: "",
selectAll: "true",
fromDate: "",
toDate: "",
selectedOrderStatus: "",
selectedCustomerCode: "",
orderNumber: "",
bosOrderNumber: "",
orderPlacedDate: "30",
downloadType: "CSV",
CSRFToken: token,
});
const response = await fetch(`/suppliers/my-account/downloadOrders?${params}`, {
credentials: "include",
});
return { ok: response.ok, status: response.status, csv: await response.text() };
})();Return the csv field as the downloaded order data.
Site-Specific Gotchas
- The export requires the CSRF token rendered in the orders page; do not invent or cache one across sessions.
- The endpoint is same-origin and must use the existing authenticated browser cookies via
credentials: 'include'. orderPlacedDate=30is the site's relative-date filter for the last 30 days; the other filter parameters should remain empty for an unfiltered export.- A missing token usually indicates that the session is unauthenticated or the orders page has not loaded; authenticate and reload that page before retrying.
- If navigation redirects to
https://almconnect.com.au/suppliers/login, the supplied browser session is not authenticated and the export cannot proceed until a valid session is available.
Expected Output
An object containing ok, HTTP status, and csv, where csv is the raw CSV text returned by /suppliers/my-account/downloadOrders for orders placed in the last 30 days.