Tuesday, 29 April 2014

Dynamics CRM 2013 - Extending the 10000 Record Limit when exporting to Excel

There is a restriction on exporting records to Excel in Dynamics CRM. You can only export up to 10,000 records.

If you are on premise you can modify the registry to fix this, if you are using CRM Online (or don't want to touch the registry) you can use the following code to modify the Organization attribute "maxrecordsforexporttoexcel".

public static void Main(string[] args)
        {
            OrganizationServiceProxy _serviceProxy = null;
            IOrganizationService _service;

            Uri crmURI = new Uri("https://{ORGANIZATION}.api.{crmregion}.dynamics.com/XRMServices/2011/Organization.svc");

            ClientCredentials clientCredentials = new ClientCredentials();
            clientCredentials.UserName.UserName = "username";
            clientCredentials.UserName.Password = "password";

            using (_serviceProxy = new OrganizationServiceProxy(crmURI, null, clientCredentials, null))
            {
                QueryExpression query = new QueryExpression();
                query.EntityName = "organization";
                query.ColumnSet = new ColumnSet() { AllColumns = true };
             
                _service = (IOrganizationService)_serviceProxy;
           
                EntityCollection entities = _service.RetrieveMultiple(query);
                if (entities.Entities.Count == 1)
                {
                    if (entities.Entities[0].Attributes.Contains("maxrecordsforexporttoexcel"))
                    {
                        entities.Entities[0].Attributes["maxrecordsforexporttoexcel"] = 20000;
                        _service.Update(entities.Entities[0]);
                    }
                }
            }
        }



NOTE: This function can be used for all organization attributes that are editable (the original list can be found here - http://msdn.microsoft.com/en-us/library/gg328408(v=crm.6).aspx)


Attribute Schema Name Display Name Type Description
AcknowledgementTemplateId Acknowledgement Template Lookup ID of the template to be used for acknowledgement when a user unsubscribes.
AllowAddressBookSyncs Allow Address Book Synchronization Boolean Indicates whether background address book synchronization in Microsoft Office Outlook is allowed.
AllowAutoResponseCreation Allow Automatic Response Creation Boolean Indicates whether automatic response creation is allowed.
AllowAutoUnsubscribe Allow Automatic Unsubscribe Boolean Indicates whether automatic unsubscribe is allowed.
AllowAutoUnsubscribeAcknowledgement Allow Automatic Unsubscribe Acknowledgement Boolean Indicates whether automatic unsubscribe acknowledgement email is allowed to send.
AllowClientMessageBarAd Allow Outlook Client Message Bar Advertisement Boolean Indicates whether the Microsoft Dynamics CRM for Outlook message bar advertisement is allowed.
AllowEntityOnlyAudit Allow Entity Level Auditing Boolean Indicates whether auditing of changes to entity is allowed when no attributes have changed.
AllowMarketingEmailExecution Allow Marketing Email Execution Boolean Indicates whether marketing emails execution is allowed.
AllowOfflineScheduledSyncs Allow Offline Scheduled Synchronization Boolean Indicates whether background offline synchronization in Microsoft Office Outlook is allowed.
AllowOutlookScheduledSyncs Allow Scheduled Synchronization Boolean Indicates whether scheduled synchronizations to Outlook are allowed.
AllowUnresolvedPartiesOnEmailSend Allow Unresolved Address Email Send Boolean Indicates whether users are allowed to send email to unresolved parties (parties must still have an email address).
AllowUserFormModePreference Allow User Form Mode Preference Boolean Indicates whether individuals can select their form mode preference in their personal options.
AllowUsersSeeAppdownloadMessage Allow the showing tablet application notification bars in a browser. Boolean Indicates whether showing tablet application notification bars in a browser is allowed.
AllowWebExcelExport Allow Export to Excel Boolean Indicates whether web-based export of grids to Microsoft Office Excel is allowed.
AMDesignator AM Designator String AM designator to use throughout Microsoft Dynamics CRM.
BaseCurrencyId Currency Lookup ID of the base currency of the organization.
BaseCurrencyPrecision Base Currency Precision Integer Number of decimal places that can be used for the base currency.
BaseCurrencySymbol Base Currency Symbol String Symbol used for the base currency.
BaseISOCurrencyCode Base ISO Currency Code String Base ISO currency code.
BingMapsApiKey Bing Maps API Key String API Key to be used in requests to Bing Maps services.
BlockedAttachments Block Attachments String Prevent upload or download of certain attachment types that are considered dangerous.
BulkOperationPrefix Bulk Operation Prefix String Prefix used for bulk operation numbering.
BusinessClosureCalendarId Business Closure Calendar Unique identifier ID of the business closure calendar of organization.
CalendarType Calendar Type Integer Calendar type for the system. Set to Gregorian US by default.
CampaignPrefix Campaign Prefix String Prefix used for campaign numbering.
CasePrefix Case Prefix String Prefix to use for all cases throughout Microsoft Dynamics CRM.
ContractPrefix Contract Prefix String Prefix to use for all contracts throughout Microsoft Dynamics CRM.
CreatedBy Created By Lookup ID of the user who created the organization.
CreatedOn Created On DateTime Date and time when the organization was created.
CreatedOnBehalfBy Created By (Delegate) Lookup ID of the delegate user who created the organization.
CurrencyDecimalPrecision Currency Decimal Precision Integer Number of decimal places that can be used for currency.
CurrencyDisplayOption Display Currencies Using Picklist Indicates whether to display money fields with currency code or currency symbol.
CurrencyFormatCode Currency Format Code Picklist Information about how currency symbols are placed throughout Microsoft Dynamics CRM.
CurrencySymbol Currency Symbol String Symbol used for currency throughout Microsoft Dynamics CRM.
CurrentBulkOperationNumber Current Bulk Operation Number Integer Current bulk operation number.
CurrentCampaignNumber Current Campaign Number Integer Current campaign number.
CurrentCaseNumber Current Case Number Integer First case number to use.
CurrentContractNumber Current Contract Number Integer First contract number to use.
CurrentImportSequenceNumber Current Import Sequence Number Integer Import sequence to use.
CurrentInvoiceNumber Current Invoice Number Integer First invoice number to use.
CurrentKbNumber Current Article Number Integer First article number to use.
CurrentOrderNumber Current Order Number Integer First order number to use.
CurrentParsedTableNumber Current Parsed Table Number Integer First parsed table number to use.
CurrentQuoteNumber Current Quote Number Integer First quote number to use.
DateFormatCode Date Format Code Picklist Information about how the date is displayed throughout Microsoft Dynamics CRM.
DateFormatString Date Format String String String showing how the date is displayed throughout Microsoft Dynamics CRM.
DateSeparator Date Separator String Character used to separate the month, the day, and the year in dates throughout Microsoft Dynamics CRM.
DecimalSymbol Decimal Symbol String Symbol used for decimal in Microsoft Dynamics CRM.
DefaultCountryCode Default Country Code String Text area to enter default country code.
DefaultEmailServerProfileId Email Server Profile Lookup ID of the default email server profile.
DefaultEmailSettings Default Email Settings String XML string containing the default email settings that are applied when a user or queue is created.
DefaultRecurrenceEndRangeType Default Recurrence End Range Type Picklist Type of default recurrence end range date.
DisabledReason Disabled Reason String Reason for disabling the organization.
EmailConnectionChannel Email Connection Channel Picklist Select if you want to use the Email Router or server-side synchronization for email processing.
EmailCorrelationEnabled Use Email Correlation Boolean Flag to turn email correlation on or off.
EmailSendPollingPeriod Email Send Polling Frequency Integer Normal polling frequency used for sending email in Microsoft Office Outlook.
EnableBingMapsIntegration Enable Integration with Bing Maps Boolean Enable Integration with Bing Maps.
EnablePricingOnCreate Enable Pricing On Create Boolean Enable pricing calculations on a Create call.
EnableSmartMatching Enable Smart Matching Boolean Use Smart Matching.
ExpireSubscriptionsInDays Days to Expire Subscriptions Integer Maximum number of days before deleting inactive subscriptions.
FeatureSet Feature Set String Features to be enabled as an XML BLOB.
FiscalCalendarStart Fiscal Calendar Start DateTime Start date for the fiscal period that is to be used throughout Microsoft Dynamics CRM.
FiscalPeriodFormat Fiscal Period Format String Information that specifies how the name of the fiscal period is displayed throughout Microsoft Dynamics CRM.
FiscalPeriodFormatPeriod Format for Fiscal Period Picklist Format in which the fiscal period will be displayed.
FiscalPeriodType Fiscal Period Type Integer Type of fiscal period used throughout Microsoft Dynamics CRM.
FiscalSettingsUpdated Is Fiscal Settings Updated Boolean Information that specifies whether the fiscal settings have been updated.
FiscalYearDisplayCode Fiscal Year Display Integer Information that specifies whether the fiscal year should be displayed based on the start date or the end date of the fiscal year.
FiscalYearFormat Fiscal Year Format String Information that specifies how the name of the fiscal year is displayed throughout Microsoft Dynamics CRM.
FiscalYearFormatPrefix Prefix for Fiscal Year Picklist Prefix for the display of the fiscal year.
FiscalYearFormatSuffix Suffix for Fiscal Year Picklist Suffix for the display of the fiscal year.
FiscalYearFormatYear Fiscal Year Format Year Picklist Format for the year.
FiscalYearPeriodConnect Fiscal Year Period Connector String Information that specifies how the names of the fiscal year and the fiscal period should be connected when displayed together.
FullNameConventionCode Full Name Display Order Picklist Order in which names are to be displayed throughout Microsoft Dynamics CRM.
FutureExpansionWindow Future Expansion Window Integer Specifies the maximum number of months in future for which the recurring activities can be created.
GenerateAlertsForErrors Generate Alerts For Errors Boolean Indicates whether alerts will be generated for errors.
GenerateAlertsForInformation Generate Alerts For Information Boolean Indicates whether alerts will be generated for information.
GenerateAlertsForWarnings Generate Alerts For Warnings Boolean Indicates whether alerts will be generated for warnings.
GetStartedPaneContentEnabled Is Get Started Pane Content Enabled Boolean Indicates whether Get Started content is enabled for this organization.
GoalRollupExpiryTime Rollup Expiration Time for Goal Integer Number of days after the goal's end date after which the rollup of the goal stops automatically.
GoalRollupFrequency Automatic Rollup Frequency for Goal Integer Number of hours between automatic rollup jobs .
HashDeltaSubjectCount Hash Delta Subject Count Integer Maximum difference allowed between subject keywords count of the email messaged to be correlated.
HashFilterKeywords Hash Filter Keywords String Filter subject keywords.
HashMaxCount Hash Max Count Integer Maximum number of subject keywords or recipients used for correlation.
HashMinAddressCount Hash Min Address Count Integer Minimum number of recipients required to match for email messaged to be correlated
IgnoreInternalEmail Ignore Internal Email Boolean Indicates whether incoming email sent by internal Microsoft Dynamics CRM users or queues should be tracked.
IncomingEmailExchangeEmailRetrievalBatchSize Exchange Email Retrieval Batch Size Integer Setting for the Async Service Mailbox Queue. Defines the retrieval batch size of exchange server.
InitialVersion Initial Version String Initial version of the organization.
IntegrationUserId Integration User Unique identifier ID of the integration user for the organization.
InvoicePrefix Invoice Prefix String Prefix to use for all invoice numbers throughout Microsoft Dynamics CRM.
IsAppMode Is Application Mode Enabled Boolean Indicates whether loading of Microsoft Dynamics CRM in a browser window that does not have address, tool, and menu bars is enabled.
IsAuditEnabled Is Auditing Enabled Boolean Enable or disable auditing of changes.
IsAutoSaveEnabled Auto Save Enabled Boolean Information on whether auto save is enabled.
IsDefaultCountryCodeCheckEnabled Enable or disable country code selection Boolean Enable or disable country code selection.
IsDisabled Is Organization Disabled Boolean Information that specifies whether the organization is disabled.
IsDuplicateDetectionEnabled Is Duplicate Detection Enabled Boolean Indicates whether duplicate detection of records is enabled.
IsDuplicateDetectionEnabledForImport Is Duplicate Detection Enabled For Import Boolean Indicates whether duplicate detection of records during import is enabled.
IsDuplicateDetectionEnabledForOfflineSync Is Duplicate Detection Enabled For Offline Synchronization Boolean Indicates whether duplicate detection of records during offline synchronization is enabled.
IsDuplicateDetectionEnabledForOnlineCreateUpdate Is Duplicate Detection Enabled for Online Create/Update Boolean Indicates whether duplicate detection during online create or update is enabled.
IsFiscalPeriodMonthBased Is Fiscal Period Monthly Boolean Indicates whether the fiscal period is displayed as the month number.
IsPresenceEnabled Presence Enabled Boolean Information on whether IM presence is enabled.
IsSOPIntegrationEnabled Is Sales Order Integration Enabled Boolean Enable sales order processing integration.
IsUserAccessAuditEnabled Is User Access Auditing Enabled Boolean Enable or disable auditing of user access.
ISVIntegrationCode ISV Integration Mode Picklist Indicates whether loading of Microsoft Dynamics CRM in a browser window that does not have address, tool, and menu bars is enabled.
KbPrefix Article Prefix String Prefix to use for all articles in Microsoft Dynamics CRM.
LanguageCode Language Integer Preferred language for the organization.
LocaleId Locale Integer ID of the locale of the organization.
LongDateFormatCode Long Date Format Integer Information that specifies how the Long Date format is displayed in Microsoft Dynamics CRM.
MaxAppointmentDurationDays Max Appointment Duration Integer Maximum number of days an appointment can last.
MaximumActiveBusinessProcessFlowsAllowedPerEntity Maximum active business process flows per entity Integer Maximum number of active business process flows allowed per entity
MaximumTrackingNumber Max Tracking Number Integer Maximum tracking number before recycling takes place.
MaxRecordsForExportToExcel Max Records For Excel Export Integer Maximum number of records that will be exported to a static Microsoft Office Excel worksheet when exporting from the grid.
MaxRecordsForLookupFilters Max Records Filter Selection Integer Maximum number of lookup and picklist records that can be selected by user for filtering.
MaxUploadFileSize Max Upload File Size Integer Maximum allowed size of an attachment.
MetadataSyncLastTimeOfNeverExpiredDeletedObjects The last date/time for never expired metadata tracking deleted objects DateTime What is the last date/time where there are metadata tracking deleted objects that have never been outside of the expiration period.
MetadataSyncTimestamp Metadata sync version BigInt Contains the maximum version number for attributes used by metadata synchronization that have changed.
MinAddressBookSyncInterval Min Address Synchronization Frequency Integer Normal polling frequency used for address book synchronization in Microsoft Office Outlook.
MinOfflineSyncInterval Min Offline Synchronization Frequency Integer Normal polling frequency used for background offline synchronization in Microsoft Office Outlook.
MinOutlookSyncInterval Min Synchronization Frequency Integer Minimum allowed time between scheduled Outlook synchronizations.
ModifiedBy Modified By Lookup ID of the user who last modified the organization.
ModifiedOn Modified On DateTime Date and time when the organization was last modified.
ModifiedOnBehalfBy Modified By (Delegate) Lookup ID of the delegate user who last modified the organization.
Name Organization Name String Name of the organization. The name is set when Microsoft Dynamics CRM is installed and should not be changed.
NegativeCurrencyFormatCode Negative Currency Format Integer Information that specifies how negative currency numbers are displayed throughout Microsoft Dynamics CRM.
NegativeFormatCode Negative Format Picklist Information that specifies how negative numbers are displayed throughout Microsoft Dynamics CRM.
NextCustomObjectTypeCode Next Entity Type Code Integer Next entity type code to use for custom entities.
NextTrackingNumber Next Tracking Number Integer Next token to be placed on the subject line of an email message.
NotifyMailboxOwnerOfEmailServerLevelAlerts Notify Mailbox Owner Of Email Server Level Alerts Boolean Indicates whether mailbox owners will be notified of email server profile level alerts.
NumberFormat Number Format String Specification of how numbers are displayed throughout Microsoft Dynamics CRM.
NumberGroupFormat Number Grouping Format String Specifies how numbers are grouped in Microsoft Dynamics CRM.
NumberSeparator Number Separator String Symbol used for number separation in Microsoft Dynamics CRM.
OrderPrefix Order Prefix String Prefix to use for all orders throughout Microsoft Dynamics CRM.
OrganizationId Organization Unique identifier ID of the organization.
OrgDbOrgSettings Organization Database Organization Settings String Organization settings stored in Organization Database.
ParsedTableColumnPrefix Parsed Table Column Prefix String Prefix used for parsed table columns.
ParsedTablePrefix Parsed Table Prefix String Prefix used for parsed tables.
PastExpansionWindow Past Expansion Window Integer Specifies the maximum number of months in past for which the recurring activities can be created.
PinpointLanguageCode Pinpoint Language Code Integer Language code to use for Pinpoint.
PMDesignator PM Designator String PM designator to use throughout Microsoft Dynamics CRM.
PricingDecimalPrecision Pricing Decimal Precision Integer Number of decimal places that can be used for prices.
PrivilegeUserGroupId Privilege User Group Unique identifier ID of the default privilege for users in the organization.
QuickFindRecordLimitEnabled Quick Find Record Limit Enabled Boolean Indicates whether a quick find record limit should be enabled for this organization (allows for faster Quick Find queries but prevents overly broad searches).
QuotePrefix Quote Prefix String Prefix to use for all quotes throughout Microsoft Dynamics CRM.
RecurrenceDefaultNumberOfOccurrences Recurrence Default Number of Occurrences Integer Specifies the default value for number of occurrences field in the recurrence dialog.
RecurrenceExpansionJobBatchInterval Recurrence Expansion Job Batch Interval Integer Specifies the interval (in seconds) for pausing expansion job.
RecurrenceExpansionJobBatchSize Recurrence Expansion On Demand Job Batch Size Integer Specifies the value for number of instances created in on demand job in one shot.
RecurrenceExpansionSynchCreateMax Recurrence Expansion Synchronization Create Maximum Integer Specifies the maximum number of instances to be created synchronously after creating a recurring appointment.
ReferenceSiteMapXml Reference SiteMap XML String XML string that defines the navigation structure for the application. This is the site map from the previously upgraded build and is used in a 3-way merge during upgrade.
RenderSecureIFrameForEmail Render Secure Frame For Email Boolean Flag to render the body of email in the Web form in an IFRAME with the security='restricted' attribute set. This is additional security but can cause a credentials prompt.
ReportScriptErrors Report Script Errors Picklist Picklist for selecting the organization preference for reporting scripting errors.
RequireApprovalForQueueEmail Is Approval For Queue Email Required Boolean Indicates whether Send As Other User privilege is enabled.
RequireApprovalForUserEmail Is Approval For User Email Required Boolean Indicates whether Send As Other User privilege is enabled.
SampleDataImportId Sample Data Import Unique identifier ID of the sample data import job.
SchemaNamePrefix Customization Name Prefix String Prefix used for custom entities and attributes.
ShareToPreviousOwnerOnAssign Share To Previous Owner On Assign Boolean Information that specifies whether to share to previous owner on assign.
ShowWeekNumber Show Week Number Boolean Information that specifies whether to display the week number in calendar displays throughout Microsoft Dynamics CRM.
SignupOutlookDownloadFWLink CRMForOutlookDownloadURL String Specifies the Microsoft Dynamics CRM for Outlook download URL.
SiteMapXml SiteMap XML Memo XML string that defines the navigation structure for the application.
SQMEnabled Is SQM Enabled Boolean Setting for SQM data collection, 0 no, 1 yes enabled
SupportUserId Support User Unique identifier ID of the support user for the organization.
SystemUserId System User Unique identifier ID of the system user for the organization.
TagMaxAggressiveCycles Auto-Tag Max Cycles Integer Maximum number of aggressive polling cycles executed for email auto-tagging when a new email is received.
TagPollingPeriod Auto-Tag Interval Integer Normal polling frequency used for email receive auto-tagging in Outlook.
TimeFormatCode Time Format Code Picklist Information that specifies how the time is displayed throughout Microsoft Dynamics CRM.
TimeFormatString Time Format String String Text for how time is displayed in Microsoft Dynamics CRM.
TimeSeparator Time Separator String Text for how the time separator is displayed throughout Microsoft Dynamics CRM.
TokenExpiry Token Expiration Duration Integer Duration used for token expiration.
TokenKey Token Key String Token key.
TrackingPrefix Tracking Prefix String History list of tracking token prefixes.
TrackingTokenIdBase Tracking Token Base Integer Base number used to provide separate tracking token identifiers to users belonging to different deployments.
TrackingTokenIdDigits Tracking Token Digits Integer Number of digits used to represent a tracking token identifier.
UniqueSpecifierLength Unique String Length Integer Number of characters appended to invoice, quote, and order numbers.
UserAccessAuditingInterval User Authentication Auditing Interval Integer The interval at which user access is checked for auditing.
UseReadForm Use Read-Optimized Form Boolean Indicates whether the read-optimized form should be enabled for this organization.
UserGroupId User Group Unique identifier ID of the default group of users in the organization.
UseSkypeProtocol User Skype Protocol Boolean Indicates default protocol selected for organization.
UTCConversionTimeZoneCode UTC Conversion Time Zone Code Integer Time zone code that was in use when the record was created.
V3CalloutConfigHash V3 Callout Hash String Hash of the Microsoft Dynamics CRM 3.0 callout configuration file.
VersionNumber Version Number BigInt Version number of the organization.
WeekStartDayCode Week Start Day Code Picklist Designated first day of the week throughout Microsoft Dynamics CRM.
YammerGroupId Yammer Group Id Integer Denotes the Yammer group ID.
YammerNetworkPermalink Yammer Network Permalink String Denotes the Yammer network permalink
YammerOAuthAccessTokenExpired Yammer OAuth Access Token Expired Boolean Denotes whether the OAuth access token for Yammer network has expired
YammerPostMethod Internal Use Only Picklist For internal use only.
YearStartWeekCode Year Start Week Code Integer Information that specifies how the first week of the year is specified in Microsoft Dynamics CRM.