@Replace (Formula Language)
Performs a find-and-replace operation on a text list.
Syntax
@Replace( sourcelist ; fromlist ; tolist )
Parameters
sourcelist
Text list. The list whose values you want to scan.
fromlist
Text list. A list containing the values that you want to replace.
tolist
Text list. A list containing the replacement values.
Return value
replacedList
Text list. The sourcelist, with any values from fromlist replaced by the corresponding value in tolist. If none of the values in fromlist matched the values in sourcelist, then sourcelist is returned unaltered.
Examples
With this example, both sourcelist and fromlist contain "Orange", which is the first value in fromlist. The first value in tolist replaces "Orange" in sourcelist. No other matches were found, so the remainder of sourcelist is left intact; the result is shown as follows:@Replace("Red":"Orange":"Yellow":"Green";"Orange":"Blue";"Black":"Brown")
sourcelist |
fromlist |
tolist |
result |
---|---|---|---|
Red |
Orange |
Black |
Red |
Orange |
Blue |
Brown |
Black (replaces "Orange") |
Yellow |
Yellow |
||
Green |
Green |
In this example, the formula looks at the Categories field in each document that it runs against. If one of the keywords in a document's Categories field is "To be assigned" then that keyword is replaced with the name stored in that document's AssignedTo field.
FIELD Categories:= @Trim(@Replace(Categories;
"To be assigned"; AssignedTo));
You have a database where you log service requests. Incoming requests are automatically categorized as "To be assigned" by a mail/paste filter. Each day, you review the new (unassigned) service requests, and assign them to technicians by entering the appropriate name in the AssignedTo field. Once a request has been assigned, you want it to appear under that technician's name in the view, instead of under "To be assigned."
Rather than manually categorizing each document a second time, you can write a filter macro, like the preceding one, to delete the documents from the "To be assigned" category and add them to the appropriate technician categories.