Replace Function
- 1 Minute to read
- Print
- DarkLight
- PDF
Replace Function
- 1 Minute to read
- Print
- DarkLight
- PDF
Article summary
Did you find this summary helpful?
Thank you for your feedback
Version 4.2.3.1
Overview
Accessible through Engineering->Function Field
REPLACE(A,B,C) in string functions
where A is the source field, B is the original string to search for and C is new string replace B
Example
The following script will create a new field from occupation, replacing "programmer" with "coder"
and report and changes made
[
{
"method": "StartErrorLog",
"filename": "ErrorLog",
"mailTo": [],
"project": "D6"
},
{
"method": "BuildBakedField",
"targetTable": "customer",
"overwrite": true,
"name": "modified-occupation",
"function": "string",
"p1": "REPLACE(A,B,C)",
"p2": "occupation",
"p3": "programmer",
"p4": "coder",
"project": "D6"
},
{
"method": "LogChanges",
"fromField": "customer.occupation",
"toField": "customer.modified-occupation",
"project": "D6"
}
]
Result
ErrorLog
Start: 2022-02-03 01:10:57
End: 2022-02-03 01:10:58
Errors:
Info:
LogChanges customer.occupation -> customer.modified-occupation
Rows Processed : 14
Rows Changed : 4
Rows Kept : 10
"junior programmer" -> "junior coder" : 1,262,462
"lead programmer" -> "lead coder" : 561,282
"programmer" -> "coder" : 2,735,469
"senior programmer" -> "senior coder" : 1,750,315
Advanced Form
Multiple replaces can be executed in the same code by changing keys p3 and p4 into arrays of strings.
{
"method": "BuildBakedField",
"targetTable": "customer",
"overwrite": true,
"name": "modified-occupation",
"function": "string",
"p1": "REPLACE(A,B,C)",
"p2": "occupation",
"p3": [
"programmer",
"tester"
],
"p4": [
"coder",
"qa"
],
"project": "D6"
}
Was this article helpful?