GetDistinctValuesImportFile Message (CrmService)
| Works for all deployment types | Works online only |
Returns distinct values for a column in the source file that contains list values.
The relevant classes are specified in the following table.
Remarks
To use this message, pass an instance of the GetDistinctValuesImportFileRequest class as the request parameter in the Execute method.
To perform this action, the caller must have access rights on the import file entity instance. For a list of required privileges, see GetDistinctValuesImportFile Privileges.
Use this message only after you have created a parse table by using the ParseImport message.
Do not use this message after you use the ImportRecordsImport message. You cannot access the parse table after the import job submitted by the ImportRecordsMessage message has finished running.
Example
The following sample code shows how to use the GetDistinctValuesImportFile message. For a complete sample, download the SDK sample code and look at SDK\Server\FullSample\DataMigration.
// Set up the CRM service.
CrmAuthenticationToken token = new CrmAuthenticationToken();
// You can use enums.cs from the SDK\Helpers folder to get the enumeration for Active Directory authentication.
token.AuthenticationType = 0;
token.OrganizationName = "AdventureWorksCycle";
CrmService service = new CrmService();
service.Url = "http://<servername>:<port>/mscrmservices/2007/crmservice.asmx";
service.CrmAuthenticationTokenValue = token;
service.Credentials = System.Net.CredentialCache.DefaultCredentials;
// Retrieve the first 2 distinct values for column 1 from the parse table.
// Note: You must create the parse table first using the ParseImport message.
// The parse table is not accessible after ImportRecordsImportResponse is called.
GetDistinctValuesImportFileRequest distinctValuesRequest = new GetDistinctValuesImportFileRequest();
distinctValuesRequest.columnNumber = 1;
distinctValuesRequest.ImportFileId = new Guid("1DCDEE97-35BB-44BE-8353-58BC36592656");
distinctValuesRequest.pageNumber = 1;
distinctValuesRequest.recordsPerPage = 2;
GetDistinctValuesImportFileResponse distinctValuesResponse = (GetDistinctValuesImportFileResponse)service.Execute(distinctValuesRequest);
// Output the distinct values. In this case, the values are (column 1, row 1) and (column 1, row 2).
int cellNum = 1;
foreach(string cellValue in distinctValuesResponse.Values)
{
Console.WriteLine("(1, " + cellNum.ToString() + "): " + cellValue);
Console.WriteLine(cellValue);
cellNum++;
}
See Also
Concepts
Reference
© 2009 Microsoft Corporation. All rights reserved.