Archive for May, 2018

SQL Server Installation – VS Shell installation has failed with exit code 1638

I was getting below error during the SQL server 2017 installation.

VS Shell installation has failed with exit code 1638


  • Exit code 1638 denotes “Another version of this program is already installed”.
  • In my case, I already had Visual Studio 2017 installed on my machine and there was conflict due to “Microsoft Visual C++ 2017 Redistributable” components which got installed with Visual Studio 2017.


This issue was annoying and had to spend couple hours to find the actual reason and fix. Below fix worked in my case.

  • Uninstall Visual Studio 2017
  • Go to Control Panel and uninstall below ‘Microsoft Visual C++ 2017 Redistributable‘ components

VC Redist

  • Restart the machine
  • Try installing SQL Server
  • Proceed with Visual Studio 2017 installation



‘Portal Comment’ not showing up – Dynamics Portals

‘Portal Comment’ is an OOB activity which comes with Portal solution and enables peer-to-peer interactions between Portal Users and Dynamics Users.

To add ‘Portal Comment’ for a record, go to ‘ACTIVITIES’ tab on the form and select ‘Portal Comment’.


Problem Statement:

  • ‘Portal Comment’ added from Dynamics on a record not showing up in Portal.
  • Below is a ‘Portal Comment’ added for Case record ‘Test’.


  • It was not showing up on Case record on Portal


Reason and Fix:

  • ‘Portal Comment’ will only show up on Portal, when the ‘SEND’ button clicked (i.e, Status = Completed)


  • Now, open the record in Portal and you should see the ‘Portal Comment’
    • Note: Text added in ‘Description’ field of ‘Portal Comment’ will show up on Portal


  • ‘Portal Comment’ can also be added from Portal by using ‘Add Comment’ button and it will show up in ‘ACTIVITIES’ tab of the record.


D 365 – Prevent Record’s Deactivate/Activate from Form – JScript

Lets see how we can apply our validation logic and prevent Deactivate/Activate of a record from Form.

Its a 3 step process:

  • Register script on form’s ‘OnSave’ event
  • Capture the ‘Deactivate/Activate’ event (i.e., by reading ‘SaveMode’ from Context)
  • Prevent Save operation

Below is the snippet to validate and prevent the Save by reading the type of operation (i.e., Deactivate, Activate, Auto Save, Save and Close, Save and New etc…).

Script :

function onSave(econtext) {
var eventArgs = econtext.getEventArgs();

// Capture Deactivation(i.e., SaveMode=5) or Activation(i.e., SaveMode=6)
if (eventArgs.getSaveMode() == 5 || eventArgs.getSaveMode() == 6) {
// Your business logic goes here
Xrm.Utility.alertDialog(“Preventing Deactivate or Activate”);

// Capture AutoSave event (i.e., SaveMode=70)
if (eventArgs.getSaveMode() == 70) {
Xrm.Utility.alertDialog(“Preventing Auto Save”);

// Capture ‘Save and Close’ event (i.e., SaveMode=2)
if (eventArgs.getSaveMode() == 2) {
Xrm.Utility.alertDialog(“Preventing ‘Save and Close'”);

How to use the script:

  • Register above script on form’s ‘onsave’ event.
  • Make sure you selected ‘Pass execution context as first parameter’ checkbox.


  • Save and Publish
  • Open the record and try to ‘Deactivate’ and you should get below popup.



  • Script triggers only when you Deactivate\Activate only from Form.
  • It does not work from Grids or ‘Advanced find’

Refer article for the complete list of ‘SaveMode’ values.


Categories: CRM Tags: ,

DataTable – Destory() method not removing all the rows

In one of my Dynamics portal’s requirements, I had to use Data Tables table control to bind the search results.


I used below snippet to bind the results.

var table = $(‘#customGrid‘).DataTable({
data: rows,
destroy: true,
columns: columns,
oLanguage: {
sLengthMenu: ‘Show _MENU_ items’,
sInfo: ” <b>Showing _START_ – _END_ of _TOTAL_ items</b>”,
sInfoEmpty: ‘ <b>Showing 0 – 0 of 0 items</b>’,
sEmptyTable: “No data to display”
‘columnDefs’: [

In the above snippet

  • #customGrid – Is ID of a HTML <Table> object which we use for DataTable.
    • <table id=”customGrid” class=”display”></table>
  • rows – JSon collection

Problem statement:

I am using ‘DataTable’ in one of my custom HTML Search pages

  • I was binding the Search results to the DataTable up on Search button click and have to clear the previous results when no match results found.
  • I was calling destroy() function to clear off the rows from previous Search.

if ($.fn.DataTable.isDataTable(“#customGrid”)) {

  • However, destroy() its not removing all the rows.

Reason and Fix:

  • destroy() remove all defined events and properties of DataTable object.
  • Its not clearing the <table> object rows (This may have fixed or changed in latest versions)
  •  So, to clear the rows, you must call empty() function of <table> object.
  • Below is the final code

if ($.fn.DataTable.isDataTable(“#customGrid”)) {
     // Destroy ‘DataTable’ object
    // Remove the <table> rows


Categories: Misc Tags: ,

Dynamics 365 – Broken ‘Notes’ control on the form and Fix

If you have upgraded to latest Dynamics 365 version or subscribed for 30 days trail and could not add a note or attachments in ‘Notes’ tab on form, this fix is for you.

Problem statement:

  • Could not add a Note or add attachment from ‘Notes’ control on form.
  • ‘Notes’ panel rendering as below with no ‘Enter a Note’ option


  • It seems product issue and will be fixed in future updates.

Fix worked for me:

There is no documented fix for this, however below steps worked for me.

  • Open the entities ‘Customization Form’ which you have problem with.
  • Double click and open the ‘Notes’ tab


  • Under ‘Web Client Properties’, select ‘Default tab’ property as highlighted below.


  • Save & Publish
  • Go back to the form and refresh.
  • You should see option to add Note.