Archived Content: This information is no longer maintained and is provided "as is" for your convenience.
Reference
Using the Fetch Operation
Return to TRIM Web Service Samples
The Fetch Operation is the way of telling the TRIM Web Service what information to return to the client application. It’s a comprehensive series of properties that can be used to obtain any information stored in TRIM about a record.
If we look into the Fetch Operation, we can see that it’s essentially a container for a collection of SpecificationProperty objects – for each piece of information you want to return from the Web Service, you need to supply a SpecificationProperty. The SpecificationProperty contains several properties that determine the manner in which information is returned to you, (more about those later) but the probably the most important property to set when creating a SpecifcationProperty is the Name Property that uniquely identifies the value of the metadata you want to return. Note that a Fetch is only useful when combined in a TrimRequest with a search operation.
SpecificationProperty rectitleSpec = new SpecificationProperty(); rectitleSpec.Name = "rectitle";
This example tells the TRIM Web Service that we’re looking for the title of the record to be present in the result set. To complete this, we need to append the SpecificationProperty to the Fetch operation:
Fetch fetch = new Fetch(); fetch.Items = new SpecificationProperty[] { rectitleSpec };
Combining these code snippets with the first example by including the SpecificationProperty and adding the Fetch operation to the TrimRequest, a sample that will return the title of each record found is produced.
// Construct a request object TrimRequest request = new TrimRequest(); // Construct a RecordStringSearchClause, with type // TitleWord, and argument "reef" RecordStringSearchClause clause = new RecordStringSearchClause(); clause.Type = RecordStringSearchClauseType.TitleWord; clause.Arg = "reef"; // Construct a record search, and put our search clause in it RecordSearch search = new RecordSearch(); search.Items = new RecordClause[] { clause }; // This SpecificationProperty says we want the title SpecificationProperty rectitleSpec = new SpecificationProperty(); rectitleSpec.Name = "rectitle"; // And this one says we want the date the record was Created SpecificationProperty recdatecreatedSpec = new SpecificationProperty(); recdatecreatedSpec.Name = "recdatecreated"; // Create a new Fetch Operation, and add our SpecficationProperties Fetch fetch = new Fetch(); fetch.Items = new SpecificationProperty[] { rectitleSpec, recdatecreatedSpec }; // Put our search operation AND our fetch operation into the // TrimRequest request.Items = new Operation[] { search, fetch }; // Send it off. Whatever comes back will be in response Engine engine = new Engine(); engine.Credentials = new System.Net.NetworkCredential(username, password); TrimResponse response = engine.Execute(request);