Asynchronous Processes/Wrokflows Stuck in InProgress/Waiting status in MS Dynamic CRM

What is the Issue?

CRM developer/User once in a life faces the issue regarding Asynchronous Processes stuck in same status i.e. InPrgress/Waiting/Pausing/Canceling.You can see the system job status is not changing.

AsyncWF

The Reason-

The main reason behind this issue  –

  1. Many jobs are in waiting status.
  2. Asyncoperationbase table become full due to many succeeded/canceled jobs occupied space.
  3. Asynchronous processes settings are not proper.
  4. The asynchronous workflows are not configured properly.

Solution-

The solution for this issue –

  1. Very first step is to restart the  Microsoft Dynamics CRM Asynchronous Processing Service. This might work in many cases.
  2. Many Jobs are in waiting status->
    you can update the job status to canceled and completed by creating console application or from database-
    a. Create the console and use the script –
    CancelWFProgramatically
    b. Using Database Query-
    Note- You should create restore(Checkpoint) point first before working on database directly to rollback changes if needed.
    CancelWFDB
    You can use “where statusCode=10 –Waiting”.
  3. Asyncoperationbase table become full due to many succeeded/canceled jobs occupied space –
    You need to cleanup the database by deleting the succeeded and canceled jobs-
    Make sure that only the following Async operation types are deleted if the state code of the types is 3 and the status code of the types is 30 or 32:

    • Workflow Expansion Task (1)
    • Collect SQM data (9)
    • PersistMatchCode (12)
    • FullTextCatalogIndex (25)
    • UpdateContractStates (27)
    • Workflow (10)

    CleanupScript
    If script took very long time then you should stop the script and rebuild the indexes for AsyncOperationBase as well as PrincipalObjectAccess tables. And run the script again.

  4. You can check if the values are optimal-
    • AsyncItemsInMemoryHigh
    • AsyncItemsInMemoryLow
    • AsyncStateStatusUpdateInterval
    • AsyncMaximumThreadsPerCPU
    • AsyncSelectInterval
    • AsyncSelectParallelism
    • AsyncThrottlingConfiguration
    Also you can check the ‘AsyncSdkRootDomain’ setting from  [MSCRM_CONFIG].[dbo].[DeploymentProperties]
    WFsetting1
    Recommended value of ‘AsyncSdkRootDomain’ should be same as ‘ADSdkRootDomain’. Or you can put server name as value.
    WFsetting2
  5. And Finally you can check your asynchronous work flow logic.
    There are many possibilities the workflows are stuck due to internal logic.

You have to restart the  Microsoft Dynamics CRM Asynchronous Processing Service after executing any above step.

MS Dynamics CRM Performance Diagnostics

What is the Issue?

CRM performance becomes very slow. But there is no clue what could be the reason behind slowness of CRM.

The Reason-

There might be several reasons to CRM performing very slow.
-Heavy customization on Entities
-APP Pool issue
-Asynchronous services performance
-Database issue
-Network related issues.

Solution-

Let’s see the solution for slow performance-
1.Heavy Customization on Entities-
-Try to make pages lighter by reducing the function calls on page load.
-If performance observed very slow on any event of some particular entity, check the workflows/plugins execution and try to make them asynchronous if possible. This will definitely improve the performance of your CRM.

2.Application pool issue-
-Sometimes there might be issue with application pool, which needs to be periodically recycled.

3.Asynchronous service Performance-
-This is the another issue which affects the crm performance. Restart the asynchronous service to resume/speedup the pending asynchronous workflows which are causing slowness in some operations.
-you can check here if you are facing some issue with asynchronous services-Asynchronous Processes/Wrokflows Stuck in InProgress/Waiting status in MS Dynamic CRM

4.Database issues-
-This is the common issue MS Dynamics CRM developer faces in a life. Due to heavy data loaded in database the crm might take time to perform operations like creating records, retrieving records, loading the views in some particular entity form. You can create indexes or recreate indexes if already exist, on such a tables which is having heavy load of data.  This will be improve performance more significantly.

5.Network Related issues-
-Very rarely user will face the slowness of CRM performance due to network related issues if they have some complex network structure, which causes the high latency in the network.
-In the case of NLB, slow performance issue might be observed by the CRM Users.In this case the you can check NLB settings.

MS Dynamics CRM provides the inbuilt diagnostics tool. You can use this tool to check point 1 and point 5.  You can use tool like-http://<YourCRMServerURL>/tools/diagnostics/diag.aspx

Another great tool that is built in tool available into CRM (2013 SP1 and up) is the CRM Performance Center. Try this with IE.
To activate,  log into CRM then press CTRL+Shift+Q on your keyboard. Click Enable, then click Refresh. When browsing in CRM, this will capture how long it takes components to load. This is a great alternative to tools like Fiddler and won’t require you to install additional third-party tools.

You can also refer-
Optimizing and maintaining client performance for Microsoft Dynamics CRM 2011 and CRM Online

Hope this will help you…

 

“Unsaved Changes” Message after saving the record in Ms Dynamic CRM

What is the Issue?

Sometime user saves the record, even after saving the crm shows unsaved changes on form. Also if we try to “save and close/Close” the current saved record the popup continues with message – “Unsaved changes on form”.

The Reason-

This causes due to –
1. Some JavaScript is setting the field value on ‘onLoad’ event of form.
2. Some Business Rule is setting the field value.
3. Some field/fields are locked on form and populating through script.

Solution-

To solve this issue –
1. If JavaScript function is the reason, then add check condition-
if (Xrm.Page.ui.getFormType() == 1) {
//populate your values
}
// formType=1 is for Create record
This will populate the values in fields only first time i.e. the record is not saved yet.

2. If Business Rule is the reason, then add check condition before populating values-
IF Created On does not Contains Data
Then populate values
The created On field contains data only for existing/saved records and this field
populates only once,on first save of record.

3. If some fields are locked on form and populated through javaScript-
The problem is the read only fields are not consider for saving in CRM automatically. There are 3 modes for saving the read only fields-

  • always: The value is always submitted.
  • never: The value is never submitted. When this option is set, data cannot be edited for any fields in the form for this attribute.
  • dirty (default): The value is submitted on create if it is not null, and on save only when it is changed.

You can save the read only field using setSubmitMode function as-


Importing managed solution in MS Dynamic CRM Error-A record with these values already exists.

What is the Issue?

When you try to import some managed solution to the MS CRM organization, It shows the error A record with these values already exists. A duplicate record cannot be created. Select one or more unique values and try again.”  and import fails.
When you download the import Log you can find the error as below-

ImportFailError1ImportFailError2

The reason-

This happens due to manually updated the entity in target environment and you try to import the customization on that entity.
This creates the record in CustomControlDefaultConfigBase , due to which MS CRM won’t allow you to insert new entry in database.

Solution-

The solution to import these type of entity customization ,you need to delete the old database entry of your target environment by query-

select * from CustomControlDefaultConfigBase 
where PrimaryEntityTypeCode 
in (select objecttypecode from entity 
where name = Impacted Entity’)
delete from CustomControlDefaultConfigBase 
where PrimaryEntityTypeCode =Impacted Entity ID

 

Task Scheduler Error-A specified logon session does not exist

What is the Issue?

When you try to create task in task scheduler.Under Security option you unchecks the ‘Run only when user is logged on’ and select ‘do not store passwords’ checkbox on General Tab.
On create of task the error pops up saying-An error has occurred for the task TaskName. Error message: The following error was reported: A specified logon session does not exist. It may have already been terminated..
This error will not occur if the “Run only when user is logged on” Security option on the General tab is selected.

The Reason-

This error came up whether you logs on as a Local Administrator, Domain Administrator, or any other user that had rights to log on locally. When creating a new task, this error will only occur if the Security Policy –Network access: Do not allow storage of passwords and credentials for network authentication is enabled and you select the “Run whether user is logged on or not” Security option on the General tab.

Solution-

To resolve this error you need to disable security policy-
Network access: Do not allow storage of passwords and credentials for network authentication
Follow the steps-

SECPOL.MSC => Security Settings => Local Policies => Security Options=>Network access: Do not allow storage of passwords and credentials for network authentication 

taskScheduler1

Disable the policy-

taskScheduler2