Documentation Index
Fetch the complete documentation index at: https://docs.taqtile.com/llms.txt
Use this file to discover all available pages before exploring further.
Exporting Manifest Faults to Excel with Office Scripts
This article walks throughmanifest_fault_excel_automate.ts, an Office Script that pulls fault records from the Taqtile Manifest API and writes them directly into the active Excel worksheet. It also explains how you can adapt the script to build other reports against the same API.
Unlike the Python equivalent, this script runs entirely inside Excel for the web through the Automate tab — no local Python installation, no pip install, and no separate .xlsx output file. The workbook you are looking at is the report.
What the Script Does
At a high level, the script:- Authenticates with the Manifest REST API to get a JWT token
- Sends a single GraphQL query to fetch the first 100 faults for the configured organization
- Writes a header row and one row per fault to the active worksheet
A1.
manifest_fault_excel_automate.ts file:
Requirements
- Excel for the web with an Microsoft 365 (Business or Enterprise) license that includes the Automate tab. Office Scripts are not available in the desktop or mobile versions of Excel.
- A Manifest user account with permission to read faults for the target organization.
- Your Manifest subdomain, email, password, and target organization ID.
Usage
- Open the workbook you want the report written to in Excel for the web.
- Select the Automate tab in the ribbon, then choose New Script.
- Paste the contents of
manifest_fault_excel_automate.tsinto the Code Editor pane, replacing the defaultmainstub. - Edit the three placeholders near the top of the script:
[domain]— your Manifest subdomain (used in both the REST and GraphQL URLs)username@domain.com— your Manifest login emailpassword— your Manifest password
- If your data lives under a different organization, update
orgId: [1]in the GraphQL query to the correct ID. - Click Save script, give it a name (for example, Manifest Faults Export), then click Run.
How It Works, Step by Step
1. Authentication
The script POSTs credentials to the Manifest REST endpoint:user.token, which is a JWT used as the Authorization header on the GraphQL request that follows. If the login call fails, or the response succeeds but contains no token, the script throws and Excel surfaces the error in the run pane.
2. Fetching Faults
A single GraphQL query is sent to the Manifest GraphQL endpoint:1 and returns only the fields the report needs. There is no pagination loop in this script: if you have more than 100 faults and need them all, see Adapting the Script below.
Note on the Authorization header: Office Scripts use the standard browserfetchAPI, and the token is passed directly as theAuthorizationheader value (noBearerprefix), matching the convention used by the Manifest API.
3. Writing to the Worksheet
The script writes results to the active worksheet — whichever sheet is selected when you press Run. It uses twoRange operations:
- A single
setValuescall writes the header row toA1:H1. - A
forEachover the faults writes each row individually withsetValuesonA{n}:H{n}.
| Column | Source |
|---|---|
| ID | fault.id |
| Description | fault.description |
| Created By | fault.createdByUserId |
| Resolved By | fault.resolvedByUserId |
| Created At | fault.createdAt |
| Resolved At | fault.resolvedAt |
| Asset ID | fault.asset.id |
| Asset Serial | fault.asset.serialNumber |
null values are coerced to empty strings using the ?? operator so the cells render blank rather than showing null. Faults with no associated asset write blank cells in the last two columns.
Note on dates:createdAtandresolvedAtare written exactly as the API returns them (ISO 8601 strings). Excel will display them as text. To convert them into native Excel datetimes, use a formula in an adjacent column such as=DATEVALUE(LEFT(E2,10))+TIMEVALUE(MID(E2,12,8)), or modify the script to parse and write aDateobject.
Adapting the Script for Other Reports
The script is structured in three clearly separated phases — auth, query, write — making it straightforward to swap in different queries or output shapes.Change the GraphQL Query
The query is a plain string passed in thebody of the gqlRes fetch call. To report on a different resource, replace the query string and update the data extraction path and Fault interface to match the new shape:
Add or Remove Columns
Two places control the columns: the header row written toA1:H1, and the row written inside forEach. To add a column, extend both arrays in the same order, and widen the range from H to I (or further). Keeping the header and the data row in sync is the only constraint.
Paginate Through All Results
The script fetches only the first page. To pull every fault, wrap the GraphQL call in a loop and incrementpageNumber until a page returns fewer than itemsPerPage records:
Filter Client-Side
Once the data is in memory, filter with standardArray.prototype.filter calls before writing. For example, to show only unresolved faults:
Write Faster with a Single setValues Call
The current script writes one row at a time, which is the slowest pattern in Office Scripts. For larger result sets, build a 2-D array first and write it all at once:
Format the Output
Office Scripts can also style the cells they write. For example, bolding the header row and auto-fitting the columns:Point at a Different Environment
The twofetch URLs control the target environment. Change them to switch between staging and production:
Security Note
The script currently has credentials embedded as string literals insidemain. Office Scripts do not have access to environment variables, OS-level secret stores, or the Excel Identity APIs that desktop add-ins use, so true secret management is not available in this runtime.
For shared or recurring use, prefer one of these approaches:
- Pass credentials as parameters when running through Power Automate. Office Scripts called from a flow can accept arguments, letting you store the email and password in a secured Power Automate connection or environment variable rather than in the script body.
- Restrict the script’s audience by saving it to a personal OneDrive rather than a shared SharePoint library.
- Use a service account with the minimum permissions required to read the data the report needs, rather than a privileged user account.
Summary
manifest_fault_excel_automate.ts demonstrates the typical pattern for building Manifest reports inside Excel for the web:
- Authenticate once via REST to get a token
- Run a GraphQL query for the resource you want
- Write the result directly into the active worksheet with
Range.setValues
