How to search NetSuite Site Management Tools content with SuiteQL

On this page

Site Management Tools can filter published content by type, path or tag, but it can’t search the text inside a block. NetSuite keeps every published block as records you can query. Each block is a CMS Content record, cmscontent in SuiteQL, which says where it shows, plus a custom record such as customrecordcms_text, which holds its HTML. Join cmscontent.settings to the custom record’s id, filter on the content type, and a LIKE finds every block of that type that mentions what you’re after, with its page and area.

I needed this when a store I work on retired the file host behind its downloads. The links sat inside text blocks spread over a set of landing pages, and nothing in SMT searches the text of a block. The query found every Text and HTML block in seconds. It has one condition that’s easy to leave out, and without it about one row in four pointed at the wrong block.

Where SMT keeps published content

When you publish in SMT, Oracle says the content and display information is saved as NetSuite records. The same page adds that “Only published content is available as NetSuite records.” Edits still waiting in SMT aren’t there, so a search shows what’s been published: blocks that are live, blocks that have expired, and any set to start later.

Each block is two records. The custom record for its content type holds the content. The SMT Core Content Types bundle sets these up:

Content typeCustom recordContent fieldsIn SuiteQL
TextCMS_TEXTclob_htmlcustomrecordcms_text, field custrecord_text_clob_html
HTMLCMS_HTMLclob_htmlcustomrecordcms_html, field custrecord_html_clob_html
ImageCMS_IMAGEstring_src, string_alt, string_linkcustomrecordcms_image, fields custrecord_image_string_src and so on

The SuiteQL names are the ones that worked on the account I tested. They come from the bundle, so I’d expect the same elsewhere, but a SELECT TOP 1 * on the record confirms them on yours.

The CMS Content record says how and where that content displays. Its Settings field “Identifies the ID for the custom record that stores the content”, and that’s the link between the two. These are the columns you’ll use:

ColumnWhat it holds
settingsThe ID of the custom record holding the content
cmscontenttypeThe content type, as an internal ID
pathThe page URL, without the host
global* when the block sits in an All Pages area
areanameThe area, from data-cms-area in the page template
startdate, enddateWhen the block starts and stops showing

Over REST, a row leaves out any column that’s empty, so SELECT TOP 1 * can hide global and the dates. Name the columns you want.

Look up the content type IDs first

cmscontenttype is an internal ID pointing at a CMS Content Type record. The bundle creates those records when it’s installed, so the numbers are whatever your account handed out. On the account I tested, ID 1 is a blog extension’s content type, not a core one. List yours:

SQL
SELECT id, name, label, customrecordscriptid FROM cmscontenttype ORDER BY id
idnamelabelcustomrecordscriptid
1cct_sc_blog_article_cardsBlog SpotlightCUSTOMRECORD_SC_BLOG_CCT_BLOG_CARD
2CMS_HTMLCMS HTMLCUSTOMRECORDCMS_HTML
3CMS_IMAGECMS IMAGECUSTOMRECORDCMS_IMAGE
5CMS_TEXTCMS TEXTCUSTOMRECORDCMS_TEXT
7cct_netsuite_columnsColumnsCUSTOMRECORD_CCT_NS_COLUMNS

That’s five of the ten rows. The rest are the two merchandising zone types and three more extension types. customrecordscriptid names the custom record behind each type, custom content types included, so this one query tells you which record to join for any block.

Don’t copy the numbers into your queries. Join to cmscontenttype and filter on name, and the query keeps working on an account where the numbers differ.

Find every Text block that mentions something

This finds every Text block that mentions box.com, the host the store retired:

SQL
SELECT c.id, c.path, c.global, c.areaname,
       TO_CHAR(c.startdate, 'YYYY-MM-DD') AS starts,
       TO_CHAR(c.enddate, 'YYYY-MM-DD HH24:MI') AS ends,
       t.id AS textid
FROM cmscontent c
JOIN cmscontenttype ct ON c.cmscontenttype = ct.id
JOIN customrecordcms_text t ON c.settings = t.id
WHERE ct.name = 'CMS_TEXT'
  AND LOWER(t.custrecord_text_clob_html) LIKE '%box.com%'
ORDER BY c.path, c.areaname

Each part is there for a reason.

LOWER() goes on the field because LIKE matches case exactly, and HTML gets written however its author felt that day. Keep the search term in lowercase too.

LIKE searches the whole block, markup included, so box.com matches inside an href as well as in visible text. For a link cleanup that’s what you want. The field holds the block’s entire HTML, and LIKE and LOWER both ran on it without complaint. A bare box.com also matches dropbox.com, so check your term doesn’t sit inside a longer host you didn’t mean.

TO_CHAR formats the dates. Without it they come back as a date only, in your NetSuite date format, and an end date can carry a time of day you’d otherwise lose.

Sorting by path and then areaname groups the results page by page, in the order you’ll work through them. If your account runs more than one site, add c.site to the select, because the same path can exist on each.

Any SuiteQL client will run it. I use a terminal and the script from how to give Claude Code read-only access to NetSuite.

Filter on the content type, or the join lies

The ct.name = 'CMS_TEXT' line looks redundant. The join goes to the Text record, so surely every match is a Text block? It isn’t, and this is the condition people leave out.

settings is an ID inside the content type’s own custom record. Text records have their own run of IDs, image records have theirs, and so does every custom content type. An image block whose settings is, say, 40 points at image record 40. Join that block to the Text record on settings and it matches Text record 40 too, if one exists. Nothing in the join says which record type settings belongs to.

To see how much it matters on your account, count the rows with and without the filter:

SQL
SELECT COUNT(*) AS all_rows,
       SUM(CASE WHEN ct.name = 'CMS_TEXT' THEN 1 ELSE 0 END) AS text_rows
FROM cmscontent c
JOIN cmscontenttype ct ON c.cmscontenttype = ct.id
JOIN customrecordcms_text t ON c.settings = t.id

On the account I tested, about a quarter of the joined rows weren’t Text blocks. Most were HTML blocks, and the rest were images, Columns blocks and a few extension types, each paired with a Text record that has nothing to do with it. The Box search went the same way, with about one row in four from another type, most of them HTML blocks, each with a real page and area attached. Work from that list and you’d open pages looking for links that aren’t there.

The same goes for any custom record you reach through settings. Filter on the type every time.

Search Text and HTML blocks together

HTML blocks keep their markup in the same kind of field on a different record. UNION ALL searches both in one pass, with a column saying which is which:

SQL
SELECT 'Text' AS kind, c.id, c.path, c.global, c.areaname
FROM cmscontent c
JOIN cmscontenttype ct ON c.cmscontenttype = ct.id
JOIN customrecordcms_text t ON c.settings = t.id
WHERE ct.name = 'CMS_TEXT'
  AND LOWER(t.custrecord_text_clob_html) LIKE '%box.com%'
UNION ALL
SELECT 'HTML' AS kind, c.id, c.path, c.global, c.areaname
FROM cmscontent c
JOIN cmscontenttype ct ON c.cmscontenttype = ct.id
JOIN customrecordcms_html h ON c.settings = h.id
WHERE ct.name = 'CMS_HTML'
  AND LOWER(h.custrecord_html_clob_html) LIKE '%box.com%'

Each half carries its own type filter. To cover a custom content type, add another half that joins the record named in its customrecordscriptid, with that record’s own field names.

Leave out blocks that aren’t showing

Expired blocks are still records. Oracle’s CMS Content page describes the end date as “the date and time when the content expires”, and says an empty one means the content never expires. A start date in the future means the block hasn’t appeared yet. To list only the blocks whose dates say they’re showing now:

SQL
SELECT c.id, c.path, c.areaname
FROM cmscontent c
JOIN cmscontenttype ct ON c.cmscontenttype = ct.id
JOIN customrecordcms_text t ON c.settings = t.id
WHERE ct.name = 'CMS_TEXT'
  AND LOWER(t.custrecord_text_clob_html) LIKE '%box.com%'
  AND (c.startdate IS NULL OR c.startdate <= CURRENT_DATE)
  AND (c.enddate IS NULL OR c.enddate > CURRENT_DATE)

Write the start date test with IS NULL OR. About a third of all the blocks on the account I tested had no start date, and a bare c.startdate <= CURRENT_DATE drops them without a word, because a comparison with an empty date is never true. In the Box search it cost only two rows, which is why my first version looked right.

CURRENT_DATE is on Oracle’s list of functions SuiteQL supports, which describes it as the current date in the session time zone. SYSDATE also ran and returned the same rows on the account I tested, but it isn’t on that list, and in the same query it came back on a different day from CURRENT_DATE.

For a cleanup I’d keep the expired blocks in. SMT’s Edit Visibility can change or remove a block’s dates, so an expired block can come back, old links and all.

There’s a hidden column too. Every row on the account I tested held F, so I go by the dates.

See the text around each match

A row tells you where a block is, not what it says. INSTR finds the match and SUBSTR cuts out the text around it:

SQL
SELECT c.id, c.path, c.areaname,
       SUBSTR(t.custrecord_text_clob_html,
              GREATEST(INSTR(LOWER(t.custrecord_text_clob_html), 'box.com') - 80, 1),
              200) AS context
FROM cmscontent c
JOIN cmscontenttype ct ON c.cmscontenttype = ct.id
JOIN customrecordcms_text t ON c.settings = t.id
WHERE ct.name = 'CMS_TEXT'
  AND LOWER(t.custrecord_text_clob_html) LIKE '%box.com%'

That returns up to 200 characters starting 80 before the first match. GREATEST stops the start going below 1 when the match is near the top of the block. On the account I tested most links wrapped an image, and 200 characters ran out inside the image tag, so raise the length if you need the text that follows the link.

Images with no alt text

The same pattern answers questions that have nothing to do with links. Image blocks keep their alt text in a field of its own, so finding the images without any is a null check:

SQL
SELECT c.id, c.path, c.areaname, i.custrecord_image_string_src AS src
FROM cmscontent c
JOIN cmscontenttype ct ON c.cmscontenttype = ct.id
JOIN customrecordcms_image i ON c.settings = i.id
WHERE ct.name = 'CMS_IMAGE'
  AND i.custrecord_image_string_alt IS NULL
  AND (c.enddate IS NULL OR c.enddate > CURRENT_DATE)

It leaves out expired images and keeps any set to start later, since those need alt text too. On the account I tested, most image blocks had none. SMT’s image form has an alternate text field, and nothing stops you saving without it. Missing alt text costs you in image search and for anyone using a screen reader, and this is the quickest list of what to fix.

Fixing what you find

SuiteQL only reads, so the fix happens somewhere else. Oracle says you can edit a content custom record directly and the fix shows on the site immediately. For the CMS Content record it says to make changes in SMT instead, warning that “if you make a mistake, your content could disappear from your site.” I take each block’s path and areaname from the query, fix it in SMT and publish.

Two kinds of block show beyond their path. All Pages blocks have * in global, and Oracle’s page on areas and scope says an All Pages area shows on any page that has an area with the same name. The same page says a page type area shows its content on every page of that type, such as every product detail page, and I found no column in cmscontent that marks those. On the account I tested, each All Pages block carried a different path, so read the path as a page you can edit the block from, not the only place it shows.

When the query fails

The role running the query needs to read every table in it. If it can’t read one, SuiteQL answers with “Record ‘…’ was not found” for that table, and the fix is a permission, not a typo. I cover that error, and how to find the missing permission, in why SuiteQL says “Record ‘transaction’ was not found”. The content custom records (CMS_TEXT, CMS_HTML and the rest) sit on the role’s Custom Record subtab, and Oracle lists them on its page about SMT custom record permissions. That page doesn’t cover cmscontent or cmscontenttype.

This post is part of the SuiteCommerce Advanced cluster. If you’re setting up the SuiteCommerce developer tools too, start with my production and sandbox guide. The tools I use for querying NetSuite are on the resources page.

Frequently Asked Questions

Does this find content that hasn't been published?

No. Oracle says only published content is available as NetSuite records. Changes waiting in SMT aren't in them until someone publishes.

Why does a block show on pages its path doesn't match?

It sits in an area with a wider scope. An All Pages block has * in global and shows on any page with an area of the same name. A block in a page type area shows on every page of that type.

Can I search landing page titles too?

Yes. Landing pages are in cmspage, which has url and pagetitle columns, and the same LOWER(pagetitle) LIKE pattern works there.

Do I need different queries for a sandbox?

No. A sandbox is a copy of production, so its content type IDs match. Filtering on the type's name matters when the same query runs on another company's account, where the IDs can differ.

Does the search include custom content types?

Only if you add them. Each custom content type stores its content in its own custom record, named in customrecordscriptid, with its own fields. Add a UNION ALL half for each one you want searched.

Working on a NetSuite project? Get in touch.