# `Fun_System_ReplaceField_JSON` (function)


- **Type:** FUNCTION
- **Returns:** `longtext`
- **Deterministic:** NO
- **SQL data access:** CONTAINS SQL

## Parameters

| # | Mode | Name | Type |
|---|---|---|---|
| 1 | IN | `sAllGuid` | `longtext` |
| 2 | IN | `sAllTbName` | `longtext` |
| 3 | IN | `sAllType` | `longtext` |

## Body

_Body is not pre-cached. To inspect: `mysql --defaults-file=~/.my.cnf -e 'SHOW CREATE FUNCTION `Fun_System_ReplaceField_JSON`'`._

## Narrative

**Business context:** Helper for the field-replacement (`Sp_System_ReplaceField*`) family — packages three parallel comma-separated lists (type-codes, source-table names, source-row sIds) into a nested JSON object keyed by type → table → sId.

**What it does:** Walks the comma list count via `CHAR_LENGTH` arithmetic; for each index extracts the matching token from each of the three inputs (`SUBSTRING_INDEX`), builds a one-level `JSON_OBJECT(type, JSON_OBJECT(table, sId))`, and `JSON_MERGE`s it into the running result.

**Invocation:** Status: appears orphaned. No caller in form-master, gdsmodule hooks, other routines, or xly-src. Naming sibling `Sp_System_ReplaceField*` procs exist but none reference this function. Candidate for maintainer audit — likely an abandoned refactor of the field-replacement pipeline.
