String Value Methods
Studio scripts use normal JavaScript string methods. Assign string fields with text values, and normalize external input before writing records.
Assignment
const orderNo = String(payload.input.orderNo || '').trim();
await context.form.create({
formApiName: 'orders',
title: orderNo,
data: {
order_no: orderNo,
},
});
Accepted input examples:
| Input | Normalized Value |
|---|---|
' SO-1001 ' | 'SO-1001' |
1001 | '1001' |
null | '' |
Common Methods
| Method | Use |
|---|---|
trim() | Remove leading and trailing spaces |
toLowerCase() / toUpperCase() | Normalize case before comparison |
includes(value) | Check whether text contains a token |
startsWith(value) / endsWith(value) | Check prefixes or suffixes |
split(separator) | Convert delimited text into an array |
replace(search, value) | Replace text or clean formatting |
padStart(length, value) | Fill business codes to a fixed width |
trim()
Remove spaces around user input before writing or comparing.
const orderNo = String(payload.input.orderNo || '').trim();
toLowerCase() / toUpperCase()
Normalize text case before comparison.
const email = String(record.data.email || '').trim().toLowerCase();
const isCompanyEmail = email.endsWith('@example.com');
const status = String(payload.input.status || '').trim().toUpperCase();
const isApproved = status === 'APPROVED';
includes(value)
Check whether a string contains a token.
const title = String(record.title || '');
const isUrgent = title.includes('[Urgent]');
startsWith(value) / endsWith(value)
Check prefixes and suffixes.
const serial = String(record.data.order_no || '');
const isSalesOrder = serial.startsWith('SO-');
const isCompanyEmail = email.endsWith('@example.com');
split(separator)
Convert delimited text into an array.
const tagText = String(payload.input.tags || '');
const tags = tagText
.split(',')
.map((item) => item.trim())
.filter(Boolean);
replace(search, value)
Replace text or remove formatting before using the value.
const phone = String(payload.input.phone || '').replace(/\s+/g, '');
const normalizedCode = String(payload.input.code || '').replace(/^order-/i, 'SO-');
padStart(length, value)
Fill a code to a fixed width.
const serial = String(payload.input.serial || '').padStart(6, '0');