Sunday, January 21, 2018

Implement CRM 365 online or on premise…?



Implement CRM 365 online or on premise…?


For small/Medium Business this is not a question. Budget to buy servers or using VMWare + licenses for CRM, SQL + system are too expensive. The natural answer is CRM online.

Now what about Medium\Large companies…

Big companies with call center (telephone integration) needs faster system, open the forms quickly CRM online can be a problem, too slow the only option is on premise.

CRM online contains latest version of the product with the new features, bug fixing.  

Working with on premise gives the flexibility to work with SSIS (import and export massive data) directly to database, create RDL reports (SQL command) in this case on premise.

Many companies like banks, investment houses cannot export the customer data from the companies outside in this case only on premise can be relevant.

Easy way to upgrade on premise or CRM online depends on the quality of the code, Write only supported and using SDK. In CRM online immediately customer gets the error but in on premise we can install the SP first in development environment, fix code then test environment and if all good in Production.

The conclusion for small/ medium business online can be a good solutions, depend budget, customization, integration code changes.

For large companies for now the only option should be on premise…

Hope in the future Microsoft will improve the performance.

Thanks
Rami Heleg
+972525695114 


Tuesday, January 16, 2018

DELETE USER FROM CRM - via SQL commands (DATABASE)


DELETE USER FROM CRM – via SQL commands (DATABASE)
I would like to delete CRM User and not disable the user.  Because of that I must to remove the current user from some CRM tables.
This is unsupported way for the resolution. Be sure to take a backup of both config DB and CRM DB.

The unsupported command helps to remove this CRM user
  1. Select SystemUserId from systemuser table
Run the next command:
select SystemUserId from SystemUser where DomainName like '%Test\Test%'
Save the guid for all other commands.
  1. Run the next commands in the orgaxniation Db for instance TEMP_MSCRM
DELETE dbo.SystemUserProfiles  where  SystemUserId = 'AAAAAAA-BBBB-CCCC-DDDD-EEEEEEEEEEEE'
DELETE dbo.UserSettingsBase   where  SystemUserId = 'AAAAAAA-BBBB-CCCC-DDDD-EEEEEEEEEEEE'
DELETE dbo.QueueMembership  where  SystemUserId = 'AAAAAAA-BBBB-CCCC-DDDD-EEEEEEEEEEEE'
DELETE dbo.TeamMembership  where  SystemUserId = 'AAAAAAA-BBBB-CCCC-DDDD-EEEEEEEEEEEE'
DELETE dbo.xnes_auditBase  where  xnes_user = 'AAAAAAA-BBBB-CCCC-DDDD-EEEEEEEEEEEE'
DELETE dbo.xnes_crmlogBase where  xnes_owner = 'AAAAAAA-BBBB-CCCC-DDDD-EEEEEEEEEEEE'
DELETE dbo.SystemUserRoles where  SystemUserId = 'AAAAAAA-BBBB-CCCC-DDDD-EEEEEEEEEEEE'
DELETE SystemUserBase where  SystemUserId = 'AAAAAAA-BBBB-CCCC-DDDD-EEEEEEEEEEEE'

  1. Run the next command in MSCRM_CONFIG DB
delete   SystemUserOrganizations  where CrmUserId = 'AAAAAAA-BBBB-CCCC-DDDD-EEEEEEEEEEEE'

Needs to IISRESET CRM front servers.
The reason is changes in MSCRM_CONFIG DB

Enjoy,

Rami Heleg

Monday, January 2, 2017

Add Entity to queue return error message: This object type cannot be added to a queue

Add Entity to queue return error message
{"This object type cannot be added to a queue."}

Solution should be very sample..
just update entity attributes under Communication @ Collaboration to support Queue



Thanks,
Rami Heleg

Wednesday, December 21, 2016

Hi,
Microsoft Dynamics CRM Database can be giant because many reason..
The main reason is files into CRM DB.

Attached to this article two queries.
First query to get database size per table.
Second query to get number of records – filee in Annotation table.

Enjoy,
Rami Heleg

SELECT 
 so.object_id AS ObjectID, 
 so.name AS ObjectName,        
 (CONVERT(decimal(20,4),(SUM (ps.reserved_page_count) * 8))) / 1024 As Reserved_MB, 
 (CONVERT(decimal(20,4),SUM ( 
             CASE 
                   WHEN (ps.index_id < 2) THEN (ps.in_row_data_page_count + ps.lob_used_page_count + ps.row_overflow_used_page_count) 
                   ELSE ps.lob_used_page_count + ps.row_overflow_used_page_count 
             END 
             ) * 8)) / 1024 As Data_MB, 
 (CONVERT(decimal(20,4),(CASE WHEN (SUM(used_page_count)) > 
             (SUM(CASE 
                   WHEN (ps.index_id < 2) THEN (ps.in_row_data_page_count + ps.lob_used_page_count + ps.row_overflow_used_page_count) 
                   ELSE ps.lob_used_page_count + ps.row_overflow_used_page_count 
             END 
             )) THEN (SUM(used_page_count) -           
             (SUM(CASE 
                   WHEN (ps.index_id < 2) THEN (ps.in_row_data_page_count + ps.lob_used_page_count + ps.row_overflow_used_page_count) 
                   ELSE ps.lob_used_page_count + ps.row_overflow_used_page_count 
             END 
             ))) ELSE 0 END) * 8)) / 1024 As Index_MB, 
 (SUM ( 
             CASE 
                   WHEN (ps.index_id < 2) THEN ps.row_count 
                   ELSE 0 
             END 
             )) AS [RowCount] 
 FROM sys.dm_db_partition_stats AS ps 
 INNER JOIN sys.objects AS so ON so.object_id = ps.object_id 
 WHERE so.object_id > 100 
 GROUP BY so.object_id, so.name 
 ORDER BY [Reserved_MB]Desc

=============================================================

SELECT  e.logicalname, e.ObjectTypeCode,COUNT( e.ObjectTypeCode) AS NumberOfRecords 
FROM Annotation a inner join Entity e
on a.ObjectTypeCode = e.ObjectTypeCode
GROUP BY  e.ObjectTypeCode , e.logicalname
order by NumberOfRecords desc

Saturday, December 17, 2016

Dynamic CRM: Change Binding HTTP to HTTPS

Changed CRM binding URL from Http to Https:
Server includes a few organizations.
Sound easy, why should be complex with this definition? Only add 's' to the http and change the port from 5555 to 443
If you need to do it don't forget to start in Development environment then QA and after check all system in Production
The first thing is to arrange the list we all the required changes.
I created my task and I assume your tasks should be the same -/+.
1.    Changing Binding Type in Deployment Tool
2.    Define binding in IIS Microsoft Dynamics CRM site to work Https + add certification.
Create a valid Certificate and don’t forget to remove the http records.
3.    Register: under HLM\SOFTWARE\Microsoft\MSCRM, change manual the ServerUrl to Https
4. Jobs: Change CRM URL in app Config.
5. User Windows Services: I assume app config contains CRM URL change
connections.
6. Custom Website that opens CRM pages for instance invokes CRM pages or requesting CRM SDK: update web.config
7. Update code/configuration file in custom website that CRM call to services from this sites.
Site from binding HTTPS call to service from HTTP binding for instance WCF can be security problem.
Another example calls window.openModalDialog unable to get response to CRM in JS.
8. SSIS update parameters.
9. Java Script: check in all file if use hard coded http.
10. Plugins the same search for hard coded.
11. Configuration file. Almost every CRM implementation contain configuration entity change records if needed
12. Telephone integration or third company which calls to CRM should change the path.
13. Open port in firewall. I assume 443.

This is not easy special if Dynamics CRM exists a few years but can be done. :-)

Thanks, 
Rami Heleg.
+972-52-5695114

Saturday, December 10, 2016

Dynamics CRM: Loading all CRM pages is very slow

Dynamics CRM: Loading all CRM pages is very slow

I started to work with Dynamics CRM on premise or online and all the system works very slowly

Loading pages is very slow, and all the system looks busy.

Dynamics CRM is vanilla then develop reason cannot cause to this bad performance.


One of the options can be Antivirus.

When you work with CRM and open some pages for instance Edit.aspx not only the edit.aspx is downloaded from server many JavaScript + CSS + other linked pages is downloaded too

If antivirus is working check if Antivirus is scanning all the scripts and pages when you request page from CRM.

Disabled scanning CRM pages in Antivirus. I got this critical issue when MCAfee was installed on all client stations.

workaround
http://support.microsoft.com/kb/924341

https://kc.mcafee.com/corporate/index?page=content&id=KB65382&actp=search&viewlocale=en_US&searchid=1278011200919

Thanks,
Rami Heleg.
Eytan computers

+972-52-5695114

Wednesday, November 30, 2016

Houston, we have a problem – Aysnc Service is down.. Unable to restart.


Houston, we have a problem – Aysnc Service is down.. Unable to restart.
After install Framework in CRM Database server and restart we Got a major problem Async Maintaince Service is down and failed to upload..

 
Error message:
  
Host XXX : failed while monitoring asynchronous operations queue. Exception: System.InvalidCastException: Unable to cast object of type 'System.DBNull' to type 'System.String'.

at Microsoft.Crm.Asynchronous.JobDataAccess.<>c__DisplayClassc.<RetrieveSqlServerName>b__a(Object[] values)

at Microsoft.Crm.Asynchronous.JobDataAccess.ExecuteSqlOrganizationScopeAndProcessRecords(IDbCommand command, Guid organizationId, RecordProcessor recordProcessor)

at Microsoft.Crm.Asynchronous.JobDataAccess.RetrieveSqlServerName(Guid orgId)

at Microsoft.Crm.Asynchronous.JobDataAccess.UpdateJobTargetServer(AsyncJob job)

at Microsoft.Crm.Asynchronous.JobDataAccess.GetNextJob(IList`1 orgsAvailableForMaintenance, DateTime startCycleTime, Int32 maxJobsToReturn)

at Microsoft.Crm.Asynchronous.JobDataAccess.GetNextJobInAppLock(IList`1 orgsAvailableForMaintenance, DateTime startCycleTime, Int32 maxJobsToReturn)

at Microsoft.Crm.Asynchronous.JobDataAccess.SelectJobs(DateTime startCycleTime, Int32 maxJobsToRetrieve)

at Microsoft.Crm.Asynchronous.JobManager.RetrieveAndQueueJobs()

at Microsoft.Crm.Timers.Timer.InvokeElapsedWithCancellationToken(Object state)

at Microsoft.Crm.Timers.Timer.InvokeElapsed()

at Microsoft.Crm.Timers.Timer.TimerProcessor.ExecuteTimers(Object data)

at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)

at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)

at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)

at System.Threading.ThreadHelper.ThreadStart(Object obj)


 

 steps to fould the reason:

  1. Use CRM Trace when try to restart the service got the error:

  2. crm 2011 failed while monitoring asynchronous operations queue. Exception: System.InvalidCastException: Unable to cast object of type 'System.DBNull' to type 'System.String'.
  3. In CRM we have 3 organization , disabled specific one Async successs to restart.. then I checked MSCRM_Config – organization table looks perfect like all other organization..

  4. Backup problematic organization DB and remove the organization + try to import this organization got the next error message

The instance name must be the same as computer name.

 


The reason for this problem found by running this command @@servername in sql management…



How to solve:
 
 
 
select @@servername - result is NULL (should contain server name)

SP_DROPSERVER "SERVERDBNAME"

SP_ADDSERVER "SERVERDBNAME ", local


 
restart the MSSQLSERVER service



Async Maintanice servce back to life.
 
 
Enjoy,

Rami Heleg

+972-52-5695114
 

Wednesday, October 19, 2016

Failed to create Appointment.. get error: Message: Pointer record exists but referenced record of type 8 not found


ERROR to create Appointment.. get error:


Message: Pointer record exists but referenced record of type 8 not found




In my example get in the error message which guid..
Crm Exception: Message: Pointer record exists but referenced record of type 8 not found: 95d0dd28-6a70-e311-9214-005056be5eb7, ErrorCode: -2147220969





The solution:

Search in resource the record - use Database.


select * from ResourceBase

where Resourceid  = '95d0dd28-6a70-e311-9214-005056be5eb7'

and remove the record.




DELETE FROM ResourceBase WHERE ResourceId='95d0dd28-6a70-e311-9214-005056be5eb7''

problem to fix in online


Enjoy,


Rami Heleg.

Wednesday, September 14, 2016

"SYSTEM user account not found"


Set regarding field and in log get the next message "SYSTEM user account not found"

 

The reason for this message belongs to BU. Be sure in security role read Users with full read. The reason user System belong to the top business Unit and current user belong to a diffident business Unit

 

Enjoy,

Rami Heleg

Tuesday, November 24, 2015

Update Grid Fetch in client side


Here is my example to update grid request in Client Site.

create new function and check if grid is already loaded

function UpdateGridOptions() {

    var myGrid = document.getElementById("myGridExample");

   
    if (myGrid == null || myGrid .readyState != "complete") {
     
        setTimeout('UpdateGridOptions()', 1000);
        return;
    }
    if (Xrm.Page.getAttribute('accountid').getValue() != null) {
        var accountId = Xrm.Page.getAttribute('accountid').getValue()[0].id;
        var fetchXml = GetFetchForGrid(accountId, Xrm.Page.data.entity.getId());
        //update grid with new fetchXml
        myGrid .control.SetParameter("fetchXml", fetchXml);
        //Refresh grid
        myGrid .control.refresh();

    }
}
Enjoy,
Rami Heleg

Saturday, July 18, 2015

Add server to existing CRM show error: Requested value ‘Geo’ was not found.

Hi,

when i tried add another server linked to the same CRM SERVER (existing CRM\DB) got the next message..



After investigate the problem the reason is CRM installation setup files was not the last version..

after download the latest version works perfect.

Enjoy,
Rami Heleg

Thursday, May 28, 2015

Interface between systems - call to WS\ WCF service from CRM FAILED because Https request (validation errors)

Interface between systems - call to WS\ WCF service from CRM FAILED because Https request (validation errors)
The solution is to add the next code in plugin

  bool CertificateValidationCallBack(
    object sender,
    System.Security.Cryptography.X509Certificates.X509Certificate certificate,
    System.Security.Cryptography.X509Certificates.X509Chain chain,
    System.Net.Security.SslPolicyErrors sslPolicyErrors)
        {
            // If the certificate is a valid, signed certificate, return true.
            if (sslPolicyErrors == System.Net.Security.SslPolicyErrors.None)
            {
                return true;
            }
            // If there are errors in the certificate chain, look at each error to determine the cause.
            if ((sslPolicyErrors & System.Net.Security.SslPolicyErrors.RemoteCertificateChainErrors) != 0)
            {
                if (chain != null && chain.ChainStatus != null)
                {
                    foreach (System.Security.Cryptography.X509Certificates.X509ChainStatus status in chain.ChainStatus)
                    {
                        if (//(certificate.Subject == certificate.Issuer) &&
                           (status.Status == System.Security.Cryptography.X509Certificates.X509ChainStatusFlags.UntrustedRoot))
                        {
                            // Self-signed certificates with an untrusted root are valid.
                            continue;
                        }
                        else
                        {
                            if (status.Status != System.Security.Cryptography.X509Certificates.X509ChainStatusFlags.NoError)
                            {
                                // If there are any other errors in the certificate chain, the certificate is invalid,
                                // so the method returns false.
                                return false;
                            }
                        }
                    }
                }
                // When processing reaches this line, the only errors in the certificate chain are
                // untrusted root errors for self-signed certificates. These certificates are valid
                // for default Exchange Server installations, so return true.
                return true;
            }
            else
            {
                // In all other cases, return false.
                return false;
            }

        }

View Class 


Enjoy,
Rami Heleg

Interface between systems - call to WS\ WCF service from CRM

Interface between systems - call to WS\ WCF service from CRM
The easy way to call WCF service using Plugin..
Invoke plugin from JS for instance by createing temp entity record
Write the next code in plugin:

public void Execute(IServiceProvider serviceProvider){
 IOrganizationService _srv = null;
 try
 {
  IPluginExecutionContext context = (IPluginExecutionContext)serviceProvider.GetService(typeof(IPluginExecutionContext));
 IOrganizationServiceFactory factory = (IOrganizationServiceFactory)serviceProvider.GetService(typeof(IOrganizationServiceFactory));
 _srv = factory.CreateOrganizationService(context.InitiatingUserId);
  if (context.MessageName.ToLower() == "create"){
    HttpWebRequest httpWReq= HttpWebRequest)WebRequest.Create("https://service/lalala.asmx");
    ASCIIEncoding encoding = new ASCIIEncoding();
    string postData = "request";
    byte[] data = encoding.GetBytes(postData);
    httpWReq.Method = "POST";
    httpWReq.ContentType = "text/xml; charset=utf-8";
    httpWReq.Host = "iservices.service.example";
    httpWReq.ContentLength = data.Length;
    using (Stream stream = httpWReq.GetRequestStream()){
      Write(data, 0, data.Length);
      HttpWebResponse response = (HttpWebResponse)httpWReq.GetResponse();
      string responseString = new StreamReader(response.GetResponseStream()).ReadToEnd();
                    }
                }
       }
 catch (FaultException<OrganizationServiceFault> ex){}
 Catch (Exception ez){}
        }



Enjoy,
Rami Heleg