|
| 1 | +--- |
| 2 | +title: 'Script Steps' |
| 3 | +description: 'Visually guide users through your script with clear subsections' |
| 4 | +--- |
| 5 | + |
| 6 | +Script Steps let your users see what’s happening while your script runs—making complex operations easier to follow with clear, real-time visual subsections. |
| 7 | + |
| 8 | +Instead of a blank screen, users get progress feedback through titled steps, icons, colors, and descriptions—bringing transparency, trust, and a polished experience. |
| 9 | + |
| 10 | +<img src="/img/v2/scripts/steps.png" alt="script steps" style={{ width: "50%" }} /> |
| 11 | + |
| 12 | + |
| 13 | +### Basic Step |
| 14 | + |
| 15 | +Add a step with just a title: |
| 16 | + |
| 17 | +```js |
| 18 | +script.step('Loading your data...'); |
| 19 | +``` |
| 20 | + |
| 21 | +<img src="/img/v2/scripts/simple-step.png" alt="script steps" style={{ width: "50%" }} /> |
| 22 | + |
| 23 | +### Detailed Step |
| 24 | + |
| 25 | +Enhance the step with optional visuals: |
| 26 | + |
| 27 | +```js |
| 28 | +script.step({ |
| 29 | + title: 'Getting Latest Data', |
| 30 | + description: 'Fetching records from your selected table', |
| 31 | + color: 'blue', |
| 32 | + icon: 'download' |
| 33 | +}); |
| 34 | +``` |
| 35 | + |
| 36 | +<img src="/img/v2/scripts/detailed-step.png" alt="detailed step" style={{ width: "50%" }} /> |
| 37 | + |
| 38 | + |
| 39 | +## Customization Options |
| 40 | + |
| 41 | +### Colors |
| 42 | + |
| 43 | +Use colors to indicate the type of action: |
| 44 | + |
| 45 | +| Color | Use Case | |
| 46 | +|----------|----------------------------------| |
| 47 | +| `blue` | General info, loading data | |
| 48 | +| `green` | Success, completed actions | |
| 49 | +| `yellow` | Validation, warnings | |
| 50 | +| `red` | Errors, critical issues | |
| 51 | +| `purple` | Special or custom operations | |
| 52 | +| `orange` | Updates or changes | |
| 53 | +| `gray` | Background or neutral operations | |
| 54 | + |
| 55 | +### Icons |
| 56 | + |
| 57 | +Suggested icons for common use cases: |
| 58 | + |
| 59 | +| Icon | Meaning | |
| 60 | +|---------------|-----------------------------| |
| 61 | +| `download` | Fetching or retrieving data | |
| 62 | +| `upload` | Sending or submitting data | |
| 63 | +| `database` | Interacting with tables | |
| 64 | +| `sync` | Updating or syncing | |
| 65 | +| `checkCircle` | Completion or success | |
| 66 | +| `settings` | Configuration steps | |
| 67 | +| `mail` | Email-related actions | |
| 68 | + |
| 69 | + |
| 70 | +## Full Example |
| 71 | + |
| 72 | +Here’s a complete example that guides the user through an import process: |
| 73 | + |
| 74 | +```js |
| 75 | +// Step 1: Start import |
| 76 | +script.step({ |
| 77 | + title: 'Starting Import', |
| 78 | + description: 'Preparing to import customer data', |
| 79 | + color: 'blue', |
| 80 | + icon: 'database' |
| 81 | +}); |
| 82 | + |
| 83 | +const sourceTable = await input.tableAsync('Which table has your customer data?'); |
| 84 | +const targetTable = await input.tableAsync('Which table should we import to?'); |
| 85 | + |
| 86 | +// Step 2: Validate data |
| 87 | +script.step({ |
| 88 | + title: 'Checking Your Data', |
| 89 | + description: 'Making sure the data will import correctly', |
| 90 | + color: 'yellow', |
| 91 | + icon: 'checkCircle' |
| 92 | +}); |
| 93 | + |
| 94 | +const sourceRecords = await sourceTable.selectRecordsAsync(); |
| 95 | +if (sourceRecords.length === 0) { |
| 96 | + output.text('No records found to import!'); |
| 97 | + return; |
| 98 | +} |
| 99 | + |
| 100 | +// Step 3: Import records |
| 101 | +script.step({ |
| 102 | + title: 'Importing Records', |
| 103 | + description: `Moving ${sourceRecords.length} customer records`, |
| 104 | + color: 'purple', |
| 105 | + icon: 'sync' |
| 106 | +}); |
| 107 | + |
| 108 | +const newRecords = sourceRecords.map(record => ({ |
| 109 | + 'Customer Name': record.getCellValue('Name'), |
| 110 | + 'Email': record.getCellValue('Email'), |
| 111 | + 'Import Date': new Date() |
| 112 | +})); |
| 113 | + |
| 114 | +await targetTable.createRecordsAsync(newRecords); |
| 115 | + |
| 116 | +// Step 4: Finish |
| 117 | +script.step({ |
| 118 | + title: 'Import Complete', |
| 119 | + description: `Successfully imported ${newRecords.length} customers`, |
| 120 | + color: 'green', |
| 121 | + icon: 'checkCircle' |
| 122 | +}); |
| 123 | + |
| 124 | +script.clear(); |
| 125 | +output.text(`✅ Done! Imported ${newRecords.length} customer records.`); |
| 126 | +``` |
| 127 | + |
| 128 | + |
| 129 | +## Advanced Usage |
| 130 | + |
| 131 | +### Manually Clear a Step |
| 132 | + |
| 133 | +Steps auto-clear when a new one starts, but you can also clear them explicitly: |
| 134 | + |
| 135 | +```js |
| 136 | +script.step('Processing...'); |
| 137 | +await someAsyncTask(); |
| 138 | +script.clear(); |
| 139 | +``` |
| 140 | + |
| 141 | +### Handling Errors Gracefully |
| 142 | + |
| 143 | +Show errors in context to keep users informed: |
| 144 | + |
| 145 | +```js |
| 146 | +script.step({ |
| 147 | + title: 'Sending Emails', |
| 148 | + description: 'Notifying customers about their orders', |
| 149 | + color: 'blue', |
| 150 | + icon: 'mail' |
| 151 | +}); |
| 152 | + |
| 153 | +try { |
| 154 | + await sendEmails(); |
| 155 | + |
| 156 | + script.step({ |
| 157 | + title: 'Emails Sent', |
| 158 | + description: 'All customers have been notified', |
| 159 | + color: 'green', |
| 160 | + icon: 'checkCircle' |
| 161 | + }); |
| 162 | +} catch (err) { |
| 163 | + script.step({ |
| 164 | + title: 'Email Error', |
| 165 | + description: 'Could not send some emails – check your settings', |
| 166 | + color: 'red', |
| 167 | + icon: 'alert' |
| 168 | + }); |
| 169 | +} |
| 170 | +``` |
| 171 | + |
| 172 | + |
| 173 | +## Best practices |
| 174 | + |
| 175 | +### Step Titles |
| 176 | + |
| 177 | +Use descriptive, action-based titles: |
| 178 | + |
| 179 | +| ✅ Do | 🚫 Avoid | |
| 180 | +|-------------------------|--------------| |
| 181 | +| "Loading customer data" | "Step 1" | |
| 182 | +| "Sending invoices" | "Processing" | |
| 183 | +| "Updating inventory" | "Working" | |
| 184 | + |
| 185 | +### When to Use Steps |
| 186 | + |
| 187 | +Use script steps to improve clarity in: |
| 188 | + |
| 189 | +* Long-running operations (API calls, imports, etc.) |
| 190 | +* Multi-phase workflows (setup → validate → process → complete) |
| 191 | +* Any place where user feedback improves trust |
| 192 | + |
| 193 | +Avoid steps for very fast or trivial operations that don’t need explanation. |
| 194 | + |
| 195 | +### How Many Steps? |
| 196 | + |
| 197 | +* **3–7 steps** is ideal for most scripts |
| 198 | +* Too few → lack of visibility |
| 199 | +* Too many → unnecessary noise |
| 200 | + |
| 201 | +### Step Descriptions |
| 202 | + |
| 203 | +Explain **what’s happening**, not **how it’s implemented**: |
| 204 | + |
| 205 | +| ✅ Good | 🚫 Avoid | |
| 206 | +|------------------------------------------|-------------------------------------| |
| 207 | +| "Fetching latest orders from your store" | "Calling API endpoint with headers" | |
| 208 | + |
| 209 | +--- |
0 commit comments