Skip to main content
Skip table of contents

Perform Search & Replace

Tag: SearchAndReplace

The SearchAndReplace action, along with the applicable SetParam child actions, lets you automate the Search & Replace operation launched by the 'Search & Replace' button found in the Diff/Values panel in scanEZ.

Detailed Description

There can only be one Search & Replace operation per script block. But a script may consist of multiple SearchAndReplace script blocks in order to carry out multiple operations.

In the case of both <SetParam field="Action" value="Search"/> and <SetParam field="Action" value="Preview"/> the intermediary Preview dialog will be displayed and require further action to move on to the next step:
<SetParam field="Action" value="Search"/>lets you see the search results in an automatable grid; this dialog will remain open until you close it in the UI. <SetParam field="Action" value="Preview"/> lets you preview the changes that will happen before they take place, and can be set to stay idle until you continue. This grid can also be automated, using the general, grid-related actions as child actions within the SearchAndReplace script block.

If no selections are made within the Preview grid, the dialog will remain idle and an automation error will occur.

SetParam Options

Field NameCompatible Field ValuesValue Description
SourceAllFields

SelectedFields

Radio button option for item search type - Required
FieldsUser definableDesired source item names—multiple item names must be separated by a semicolon - Required
RegexSearchUser definableRegular expression to search for in document items - Required
ActionSearch

Preview

Apply

Corresponds to radio buttons to set the type of action to take if search criteria are met - Required (See detailed description)
TextReplaceUser definableDesired text to replace the RegexSearch value occurances with - Required

Example Scripts

XML
<SearchAndReplace>
	<SetParam field="Source" value="SelectedFields"/>
	<SetParam field="Fields" value="Field1;Field2;Field3"/>
	<SetParam field="RegexSearch" value="Denied"/>
	<SetParam field="TextReplace" value="Accepted"/>
	<SetParam field="Action" value="Apply"/>
</SearchAndReplace>
XML
<YtriaAutomation>
	<Load Server="ACME01/ACME" database="Mailtest.nsf"/>
	<focus target="tree" category="Documents" type="Memo"/>
	<SearchAndReplace>
		<SetParam field="Source" value="SelectedFields"/>
		<SetParam field="Fields" value="Form"/>
		<SetParam field="RegexSearch" value="Memo"/>
		<SetParam field="TextReplace" value="Email"/>
		<SetParam field="Action" value="Preview"/>
			<if test="VisibleRowsCount" mode="GreaterThan" value="0">
				<Select Lines="All"/>
				<Export>
					<SetParam field="FilePath" value="C:MemoChange.html"/>
					<SetParam field="ExportType" value="HTML"/>
					<SetParam field="SelectedRowsOnly" value="true"/>
				</Export>
			</if>
	</SearchAndReplace>
</YtriaAutomation>

In the script above, the database "Mailtest.nsf" will be loaded into scanEZ, and the selection tree focus placed on the Memo-type documents. The action SearchAndReplace will be launched all these documents, searching for the Regex "Memo" within the items named "Form". All matching Regex occurrences will be replaced with the text "Email". The action to take within the Search & Replace operation is set to '"Preview". so the dialog will open. If any Regex occurrences are found, all rows within the Preview grid will be selected, and the information exported to an HTML file. If no occurrences are found, the script will end and no values will have been changed.

JavaScript errors detected

Please note, these errors can depend on your browser setup.

If this problem persists, please contact our support.