Share via


Search and Process Development Process

Search and process operations enable you to identify—based on a search query—a certain set of list items, and then perform custom operations on those list items in bulk. For example, you might need to identify a certain set of documents, based on specific document metadata, and then move those documents into a records repository.

Following are the high-level steps for creating a search and process operation:

  1. Create the assembly to process the items you want your search to return.

    To process the returned items, your assembly must implement the IProcess interface.

  2. Compile the assembly and install it on the Microsoft Office SharePoint Server 2007 server. The assembly must be strong-named, signed, and added to the global assembly cache.

  3. Write code that creates a new SearchAndProcessItem object to represent your search and process job. This class contains properties you can use to specify the following:

    • The parameters of your search query, such as scope, stemming, noise, duplicates trimming, and the size of the return set.

    • The name of the assembly, and class within the assembly, to call to process each item returned by the search.

    • The name displayed on the e-mail report for this search and process job.

    • Any optional arguments to pass to the process assembly and class.

    • The users to send a report to by e-mail on the search and process job results.

  4. Call the Add method of the SearchAndProcessItem class to add your search and process job to the Office SharePoint Server 2007 master timer job.

    Note

    The Add method includes a parameter to specify the user on whose behalf the search and process operation is being performed. Items to which the user does not have sufficient rights are not included in the return set of the search and process operations.

    The Add method lets you specify a time when you want your job to run. The Add method throws an exception if any of the following occurs:

    • The referenced assembly cannot be found, or does not implement the IProcess interface.

    • The time you have specified for the job to run is invalid. For example, you have specified a time in the past.

    The search and process operation is created as a one-time, asynchronous timer job. The Add method returns a GUID that represents the GUID of the SPTimerJob created for this request.

The IProcess Interface

Each assembly you create to process items as part of a search and process operation must implement the IProcess interface. The IProcess interface consists of a single method, ProcessItem, which Office SharePoint Server 2007 calls for each item in the search return set. The ProcessItem method includes parameters to specify the following:

  • The item to process

  • Any optional arguments the user specified for Office SharePoint Server 2007 to pass to the assembly

  • An output parameter for the assembly to return detailed processing information to Office SharePoint Server 2007

The ProcessItem method returns a Boolean value to indicate whether the item was processed successfully.

Office SharePoint Server 2007 stores this Boolean success indicator, as well as any detailed information returned via the output parameter, for each item processed. Office SharePoint Server 2007 includes this information in the search and process job summary report that is sent in e-mail to the specified users.

See Also

Concepts

Search and Process Overview