MSCRM : Delete Reports from database

Today we needed to delete more 100 reports from our solution. This operation is boring and long to do directly on CRM. My mate Flavio found an alternative way to clean reports from Database. It is an unsupport solution but for our needs run in right way.

The queries are simple:

DECLARE @Id nvarchar(max)
DECLARE MY_CURSOR CURSOR
LOCAL STATIC READ_ONLY FORWARD_ONLY
FOR
SELECT DISTINCT ReportId From ReportBase WHERE name like('Sub Accounts %')

OPEN MY_CURSOR
FETCH NEXT FROM MY_CURSOR INTO @Id
WHILE @@FETCH_STATUS = 0
BEGIN
--Do something with Id here
PRINT @Id
DELETE FROM dbo.ReportCategoryBase WHERE ReportId = @Id
DELETE FROM dbo.ReportEntityBase WHERE ReportId = @Id
DELETE FROM dbo.ReportLinkBase WHERE ReportId = @Id
DELETE FROM dbo.ReportLinkBase Where LinkedReportId = @Id
DELETE FROM dbo.ReportVisibilityBase WHERE ReportId = @Id
DELETE FROM dbo.Dependencybase WHERE DependencyId
in(SELECT DependencyId FROM dbo.Dependency WHERE RequiredComponentObjectId = @Id)
DELETE FROM dbo.Dependencybase WHERE DependencyId
in(SELECT DependencyId FROM dbo.Dependency WHERE DependentComponentObjectId = @Id)
DELETE FROM dbo.SolutionComponentBase WHERE ObjectId = @Id
DELETE FROM dbo.DependencyNodeBase WHERE ObjectId = @Id
DELETE FROM dbo.ReportBase WHERE ReportId = @Id;

FETCH NEXT FROM MY_CURSOR INTO @Id
END
CLOSE MY_CURSOR
DEALLOCATE MY_CURSOR

That’s all.

Upgrade CRM2015 to CRM2016 : Timeout error during the upgrade

When I tried to uprade an organization from CRM2015 to CRM2016 I hade a Time out error : “The timeout period elapsed prior to completion of the operation or the server is not responding.  The wait operation timed out“.

I checked on google and I read that “You cannot import your CRM 2015 database to upgrade to CRM 2016 if it has a Full Text Catalogue. Something that is likely if you have been using the improved searching functions of CRM 2015.

To fix this problem, we have two possibilities: First one is to disable the Full-search for Quick find on CRM2105 before to migrate. But I don’t know why You need to wait a full 24 hours from the time you change this setting before you attempt to import (or backup to import) the organization into a CRM 2016 environment.

 

quickfind

if you need to resolve problem in fast way there is the second solution: This one is an update script directly on databse but it is not supported. The steps are the following:

  1. Restore backup from CRM 2015 database
  2. On the SQL manager, select the Database in question, and select “New Query” (our 2015 dates restore is demo_2016_MSCRM)s2
  3. In the new Query window. Paste the following code and click Execute
    declare @catid int
    
    select @catid=fulltext_catalog_id from sys.fulltext_catalogs where name='CRMFullTextCatalog'
    
    declare c cursor for
    
     select sys.tables.name, sys.fulltext_indexes.unique_index_id from sys.fulltext_indexes inner join sys.tables on sys.fulltext_indexes.object_id = sys.tables.object_id where sys.fulltext_indexes.fulltext_catalog_id=@catid
    
     open c
    
     declare @TableName varchar(200), @UniqueID as integer
    
     fetch next from c into @TableName, @UniqueID
    
     while @@fetch_status = 0
    
     begin
    
     declare d cursor for
    
     select sys.indexes.name, sys.tables.object_id from sys.tables inner join sys.indexes on sys.tables.object_id = sys.indexes.object_id where sys.tables.name=@TableName and sys.indexes.index_id = @UniqueID
    
     open d
    
     declare @KeyIndex varchar(200), @object_id as integer
    
     fetch next from d into @KeyIndex, @object_id
    
     if @@FETCH_STATUS <> 0 
    
     begin
    
     Print 'Error with' + @TableName
    
     end
    
     while @@fetch_status = 0
    
     begin
    
     BEGIN TRY
    
     Print 'CREATE FULLTEXT INDEX ON [dbo].'+@TableName+' KEY INDEX ['+@KeyIndex+'] on([CRMFullTextCatalog]) WITH (CHANGE_TRACKING AUTO)'
    
     Print 'GO'
    
     declare e cursor for
    
     select sys.columns.name from sys.columns inner join sys.fulltext_index_columns on sys.columns.object_id=sys.fulltext_index_columns.object_id and sys.columns.column_id=sys.fulltext_index_columns.column_id where sys.columns.object_id=@object_id
    
     open e
    
     declare @ColumnName varchar(200)
    
     fetch next from e into @ColumnName
    
     while @@fetch_status = 0
    
     begin
    
     Print 'ALTER FULLTEXT INDEX ON [dbo].'+@TableName+' Add ('+@ColumnName+')'
    
     Print 'GO'
    
     fetch next from e into @ColumnName
    
     end
    
     close e
    
     deallocate e
    
     END TRY
    
     BEGIN CATCH
    
     print 'Error' + @KeyIndex
    
     END CATCH
    
     fetch next from d into @KeyIndex, @object_id
    
     end
    
     close d
    
     deallocate d
    
     fetch next from c into @TableName, @UniqueID
    
     end
    
     close c
    
     deallocate c
    

    The complete script is on my Github: DisableFullTextSearch-Catalog.sql

  4.  When the query executes successfully. Copy to the Clipboard all of the “Message” output in the bottom half of the screen to your clipboard.s3
  5. Now Expand the “Storage / Full Text Catalogues” section of the Database in question and select Properties. s4
  6. Select Table / Views. Using the the little Left pointing arrow. s5Click it as many times as needed to move all the items on the right to the left. Like this:s6
  7. Once finished, select he Script Dropdown and select “Script Action to New Window” (or just click on OK both actions should work)s7
  8. Now Close all the Management for the SQL Server. This is Important.
  9. Upgrade your CRM database the normal way using the Microsoft Dynamics Deployment Manager / Organisations / Import Organisation
  10. Once the upgrade has finished and you have your database imported and upgraded to CRM 2016, Open the SQL manager for the database in question again, and run a new query against the database as we did in step 3 above.This time however we are going to paste the output we captured to clipboard in step 4 above, and run that output as a script.s9
  11. Click Execute again. And you should be rebuilding the database indexes to a state that will function with the new CRM upgraded database.

Source are :

  • community.dynamics.com/crm/f/117/t/184508
  • interactivewebs.com/blog/index.php/crm/crm-2016-import-upgrade-from-crm-2015-failure-timeout-expired/

 

 

 

 

 

 

 

Upgrade CRM2015 to CRM2016 : Database having version 8.0.1.79 is not supported for upgraded.

Today I had a problem to migrate CRM2015 to CRM2016. When I try to import I had this error: Database having version 8.0.1.79 is not supported for upgraded.

I thought that the problem was related with CRM database but Microsoft Community helps me to understand the problem:

The error is misleading as it has nothing to do with the version of the database. If you are trying to import an organization database that has already been imported to an organization on that crm server, you will get this error, because the organization has the same ID.

To resolve it I found two solutions:

  1. Remove the organization with the same ID from server
  2. Change server

But my mate Martin got me another possiblity: Change organization ID from database. It is an unsupported solution but for my needs is perfect. Now I executed the SQL Script and all it is import right.  If you want, you can find the script on my GITHUB: Change Organisation ID V3.sql.

 

 

CRM2016 – Wrong height Layout inside a WebResource on Form

We have a HTML Page as a webresource inside our CRM. In this webPage there are two dropdownlist. We need to manage a Due date.
This was created in the past for CRM2011 and all layout worked always in right way.

Capturecrm2011

CRM2011 – Right layout

We upgrade our CRM to CRM2016 and we start with layout problem:

Capture11

CRM2016 – Wrong layout

 

I must insert this piece of code inside my webresource:

if (typeof parent.$ !== 'undefined') //Check for CRM2011 version. Work only on CRM2015/CRM2016
{
   parent.$( document ).ready(function() {
           var elem = parent.$('#WebResource_duedate');
           elem.height('24px');
   });
}

This code works on DOM directly and change the height. The result is:
Capturenew

CRM2016 – Right Layout

CRM2013 – Save and refresh an entity without postback

Today I had a strange problematic for my client: I needed to update an hidden field without that the user niticing it. I found a solution on this blog: http://www.hebbink.com/post/2015/06/22/saving-and-refreshing-a-crm-entity-form-without-postback

function SaveAndRefresh() {
    Xrm.Page.getAttribute("myAttributeName").setValue(null);
    Xrm.Page.data.refresh(true);
}

Thanks a lot for this great solution!

Unable to activate CRM List Component in Sharepoint

Last week I installed a new CRM and Sharepoint enviroment on my client.  I had a strange problem when I tried to install and activate List Component on Sharepoint: After the installation (I did not have any problem during the process) I tried to activate List Component Plugin: The result was that the plugin was not active but I did not have any error. After some (long) minutes, I found the problem:

Inside zip package setup for CRM List Component there is a powershell file named AllowHtcExtn.ps1

We need to execute this file before activate.

On Technet we can read this :

[…By default, HTML component (.htc) files aren’t enabled on SharePoint 2013. …]

 

After we can activate our plugin.

That’s all:-)

MSCRM – Document Core Pack (DCP)

Today I want to talk about a fantastic (according to me and according my clients) add-on for Microsoft Dynamics CRM: Document Core Pack (DCP). I used from first version but now I found time to write this post:-)

DCP is an add-on to help users to create and […”manage documents associated with CRM-records in a confortable and structurated way”…]

DCP allowed to create and use different and complex documents as PDF. XPS, Doc, Docx, ODT-Files.

The main Features are: 

  1. Easy MS-Word based document generation based on CRM data
  2. Direct document generation out of MS CRM
  3. Various document processing options inside MS Word (creation of CRM activities, send PDF via Outlook,…)
  4. Automated table creation (list of quote-products, contacts from an account, activities)
  5. Embedding of pictures, HTML-content, other documents and QR-codes out of CRM or from external ressources
  6. Bulk-Merge functionality for multi-record document creation

After installation and configuration of DCP server on the CRM server and DCP client on the client,we have this new Tabs (www.mscrm-addons.com) and inside the follwing icons: on our Word (For example):

intranet

With this icons, we can manage and synchronize our documents with crm.

On CRM we have the following icon:

Unbenannt

inside the entities that we selected on the DCP server configuration. We can use template document to fill-in in automatic all information from CRM. For example when we need to create a custom document with all sales information.