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.


<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

SetParam Options

Field NameCompatible Field ValuesValue DescriptionComment
SourceAllFields

SelectedFields

Radio button option for item search typeMandatory
FieldsUser definableDesired source item names—multiple item names must be separated by a semicolonMandatory
RegexSearchUser definableRegular expression to search for in document itemsMandatory
ActionSearch

Preview

Apply

Corresponds to radio buttons to set the type of action to take if search criteria are metMandatory—see detailed description
TextReplaceUser definableDesired text to replace the RegexSearch value occurances withMandatory

Detailed Description

NOTEThere 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.


NOTEIn 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.

Example Script

<YtriaAutomation Version="1.0" Application="scanEZ" ApplicationVersion="16.5" DlgProgress="true">
	<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>
XML

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.