Skip to main content

Advanced Scripting Functions

Powerful new SDK functions for your custom code

Peter Novosel avatar
Written by Peter Novosel
Updated today

SmartSuite scripting has been expanded with a set of new functions and capabilities designed to make scripts more powerful, secure, and easier to integrate with the rest of the platform. These additions improve how scripts work with records, files, navigation, external APIs, grid context, and UI styling.

This article walks through each new capability, explains when to use it, and provides examples.


Hydrated Records

By default, record-fetching APIs return a lightweight representation of record data. You can now request hydrated records to retrieve richer field data in a single call.

When to Use

  • When your script needs additional field metadata

  • When working with complex fields such as linked records or advanced field types

  • To reduce the need for follow-up requests

Example

<script>
window.SmartSuite.get_record(
'689dcb3c206489e375d98c69',
'689dcb42206489e375d98c75',
{
fieldSlugs: ['status', 'priority', 'sd1ed48ddd'],
hydrated: true,
}
).then((res) => {
console.log('Hydrated record:', res);
});
</script>

Setting hydrated: true returns expanded field data for the requested fields.


Secure Redirection

Scripts can now safely redirect users to SmartSuite destinations such as records, tables, or solutions. All redirects are validated by SmartSuite before navigation occurs.

Supported Destinations

  • Record

  • Table (app)

  • Solution

Example

<script>
window.SmartSuite.redirect_to({
type: 'record',
solutionId: '67161745a504292e31e25acf',
appId: '64a3d0e2ae628ec2bee3c03e',
recordId: '67617ada14f3899326e28ddb',
});
</script>

The redirect occurs in the same window and only if the user has permission to access the destination.


File Downloads from Scripts

You can now trigger secure file downloads directly from a Script widget using base64-encoded data. This works entirely on the frontend and does not require server-side calls.

When to Use

  • Exporting generated reports

  • Downloading transformed data (CSV, PDF, JSON, etc.)

  • Delivering files without navigating away from the dashboard

Example (PDF)

<script>
window.SmartSuite.download_data({
name: 'summary.pdf',
mime_type: 'application/pdf',
data: 'base64PdfString',
});
</script>

Example (CSV)

<script>
window.SmartSuite.download_data({
name: 'new-file.csv',
mimeType: 'text/csv',
data: 'VXNlcm5hbWU7IElkZW50aWZpZXI7Rmlyc3QgbmFtZTtMYXN0IG5hbWUK...',
});
</script>

The browser handles conversion and download automatically if the data is valid.


Proxy Fetch for External Requests

Scripts can make external HTTP requests through a proxy fetch mechanism to avoid common CORS limitations.

Important Notes

  • URLs must be explicitly allowlisted by an administrator

  • Requests are routed through a secure SmartSuite endpoint

  • Standard HTTP methods and headers are supported

Example

<script>
window.SmartSuite.proxy_fetch({
url: 'https://jsonplaceholder.typicode.com',
options: {
method: 'GET',
headers: {
'Content-Type': 'application/json',
},
body: null,
},
}).then((res) => {
console.log('Proxy fetch result:', res);
});
</script>

Use this for calling trusted third-party APIs from within Script widgets.


Grid Selections

Scripts can now retrieve the IDs of records selected in a Grid widget. This makes it easy to build context-aware actions that operate on user selections.

When to Use

  • Bulk actions triggered from dashboards

  • Context-sensitive exports or workflows

  • Custom UI controls tied to grid state

Example

<body>
<p id="selected"></p>
<button id="get-context">Get selected records</button>

<script>
document
.getElementById('get-context')
.addEventListener('click', function () {
window.SmartSuite
.get_grid_selections('68f9e8bcbe1384dbcdb90e13')
.then((res) => {
console.log('Selected record IDs:', res);
document.getElementById('selected').innerText =
JSON.stringify(res);
});
});
</script>
</body>

The function returns a list of record IDs currently selected in the specified Grid widget.


CSS Styling for Script Widgets

Script widgets now support a set of predefined CSS classes to help maintain visual consistency with SmartSuite’s UI. These styles can be applied directly inside sandboxed iframes.

Naming Convention

All SmartSuite-provided classes use the prefix:

smartsuite_

Supported UI Elements

  • Buttons

  • Inputs (text, textarea, number, checkbox, radio, select, date, file)

  • Tables

  • Modals

  • Accordions

  • Notifications (info, error)

  • Progress bars

  • Typography

Example

<button class="button">Button</button>

<div class="smartsuite_text_input error">
<label>Text Input</label>
<input type="text" placeholder="Placeholder" />
<p>This field is required.</p>
</div>

<div class="notification error">
Error Notification: Something went wrong!
</div>

These classes allow you to build polished interfaces without managing your own CSS framework.


Best Practices

  • Validate inputs before triggering downloads or redirects

  • Use proxy fetch only for trusted, allowlisted endpoints

  • Keep scripts defensive when handling grid selections

  • Reuse SmartSuite CSS classes for consistent styling

  • Prefer hydrated records when working with complex data


These enhancements significantly expand what’s possible with SmartSuite scripting, enabling richer integrations, safer navigation, better data handling, and more professional UI experiences directly within dashboards and extensions.

Did this answer your question?