Clone cleanup script to reindex sys_user text index after clone — correct approach

AnjaliY27339946
Kilo Contributor

Environment: Australia. Clone source: Prod, targets: Dev and Test.

After our last Dev and Test refreshes, global search returns no results for most users. The records themselves are fine and display normally in the sys_user list view, they are just missing from the text index. The only users that are searchable are ones whose records happen to have been saved since the clone. Prod is unaffected.

I understand text indexes are not copied during a clone, and that the OOB "Regenerate all text indexes" cleanup script is meant to handle this.

What I have already checked on Prod (the clone source):

1. "Regenerate all text indexes" exists, Active = true, Order = 100, System Profile.
2. It is listed in the Cleanup scripts related list of the clone profile we use.
3. That profile has 33 cleanup scripts, almost all sitting at Order 100.
4. A few scripts appear twice, once under System Profile and once under our custom profile.

What I am planning to do is add our own cleanup script at a lower Order (10) that reindexes only the global search People tables, so they are queued ahead of the full all-tables regeneration. The script would loop over sys_user, sys_user_group and core_company and call new GlideTextIndexEvent().indexUpdate(tableName, 'null') on each, wrapped in a try/catch with logging so I can confirm afterwards whether it ran.

Questions:

1. Is adding a custom cleanup script to the clone profile the right way to handle this, or is there a better supported approach I am missing?

2. Does a lower Order value reliably make it run before the OOB scripts? With 33 scripts all at Order 100, is execution order within the same Order value deterministic at all?

3. Cleanup scripts have to be defined on the source instance. Is creating it directly on Prod and capturing it in an update set the accepted practice, or do others handle this differently?

4. Does firing the reindex for sys_user before the all-tables script actually place it ahead in the text_index queue, or does that queue not work that way?

Thanks in advance.

0 REPLIES 0