Monday, October 30, 2017

Connection to CRM is not established. Aborting process.

Hi All, 


Please find the below Code for CRM SVC util Sevices For Early Binding if it throws Label Error


Inside Server:

CrmSvcUtil.exe /url:http://localhost:555/ORGANIZATIONNAME/XRMServices/2011/Organization.svc /out:GeneratedCode.cs interactivelogin:true

Outside Server:

CrmSvcUtil.exe /url:https://URL/ORGNAME/XRMServices/2011/Organization.svc /out:GeneratedCode.cs interactivelogin:true

Note:

If we didn't Use interactivelogin:true then in INSIDE/OUTSIDE Server the system automatically tries to HIT Internet URL 

Error will be like below:

Microsoft.Xrm.Tooling.Connector.CrmServiceClient Error: 2 : Exception while trying to connect Discovery Server, (North America) URI is = https://disco.crm.dynamics.com/XRMServices/2011/Discovery.svc
Microsoft.Xrm.Tooling.Connector.CrmServiceClient Error: 2 : Exception while trying to connect Discovery Server, (Europe, Middle East and Africa) URI is = https://disco.crm4.dynamics.com/XRMServices/2011/Discovery.svc
Microsoft.Xrm.Tooling.Connector.CrmServiceClient Error: 2 : Exception while trying to connect Discovery Server, (Asia Pacific Area) URI is = https://disco.crm5.dynamics.com/XRMServices/2011/Discovery.svc
Microsoft.Xrm.Tooling.Connector.CrmServiceClient Error: 2 : Exception while trying to connect Discovery Server, (South America) URI is = https://disco.crm2.dynamics.com/XRMServices/2011/Discovery.svc
Microsoft.Xrm.Tooling.Connector.CrmServiceClient Error: 2 : Exception while trying to connect Discovery Server, (Oceania) URI is = https://disco.crm6.dynamics.com/XRMServices/2011/Discovery.svc
Microsoft.Xrm.Tooling.Connector.CrmServiceClient Error: 2 : Exception while trying to connect Discovery Server, (Japan) URI is = https://disco.crm7.dynamics.com/XRMServices/2011/Discovery.svc
Microsoft.Xrm.Tooling.Connector.CrmServiceClient Error: 2 : Exception while trying to connect Discovery Server, (North America 2) URI is = https://disco.crm9.dynamics.com/XRMServices/2011/Discovery.svc
Microsoft.Xrm.Tooling.Connector.CrmServiceClient Error: 2 : Exception while trying to connect Discovery Server, (Canada) URI is = https://disco.crm3.dynamics.com/XRMServices/2011/Discovery.svc
Microsoft.Xrm.Tooling.Connector.CrmServiceClient Error: 2 : Exception while trying to connect Discovery Server, (India) URI is = https://disco.crm8.dynamics.com/XRMServices/2011/Discovery.svc
Microsoft.Xrm.Tooling.Connector.CrmServiceClient Error: 2 : Exception while trying to connect Discovery Server, (Germany) URI is = https://disco.crm.microsoftdynamics.de/XRMServices/2011/Discovery.svc
Microsoft.Xrm.Tooling.Connector.CrmServiceClient Error: 2 : Exception while trying to connect Discovery Server, (United Kingdom) URI is = https://disco.crm11.dynamics.com/XRMServices/2011/Discovery.svc
Microsoft.Xrm.Tooling.Connector.CrmServiceClient Error: 2 : No Orgs Found, Searched Online. Region Setting = 
Microsoft.Xrm.Tooling.Connector.CrmServiceClient Error: 2 : Unable to Login to Dynamics CRM
CrmSvcUtil Error: 2 : Exiting program with exit code 2 due to exception : System.Exception: Connection to CRM is not established. Aborting process.
   at Microsoft.Crm.Services.Utility.SdkMetadataProviderService.LoadMetadata(IServiceProvider service)
   at Microsoft.Crm.Services.Utility.CrmSvcUtil.Run()
   at Microsoft.Crm.Services.Utility.CrmSvcUtil.Main(String[] args)
CrmSvcUtil Error: 2 : ===== DETAIL ======
CrmSvcUtil Error: 2 : Source : CrmSvcUtil
Method : LoadMetadata
Date : 13:49:39
Time : 30.10.2017
Error : Connection to CRM is not established. Aborting process.
Stack Trace : at Microsoft.Crm.Services.Utility.SdkMetadataProviderService.LoadMetadata(IServiceProvider service)
   at Microsoft.Crm.Services.Utility.CrmSvcUtil.Run()
   at Microsoft.Crm.Services.Utility.CrmSvcUtil.Main(String[] args)
======================================================================================================================


Monday, October 23, 2017

Export JQGrid Data to CSV - JavaScript


//Create Grid Table
$("#JQGridName").jqGrid({
    datatype: "local",
    colNames: ['colname'], // Pass Col Name
    colModel: [{ name: 'colval'}], // Pass Col Values
    search: true,
    pager: '#JQGridPager', // Pass Grid Pager Name
    data: ExhbReportArrayData, // Pass Value for Grid
    rowNum: 20,
    rowList: [10, 20],
    viewrecords: true,
    shrinkToFit: false,
    height: 'auto',
    fixed: false,
    multiselect: true,
    forceFit: true
});

//Add Button to Grid Pager
$("#JQGridName").jqGrid('navGrid', '#JQGridPager', { view: true, del: false, add: false, edit: false, excel: true })
.navButtonAdd('#JQGridPager', {
    caption: "Export to Excel",
    buttonicon: "ui-icon-save",
    onClickButton: function (e) {
        exportData(e, '#JQGridName');
    },
    position: "last"
});

// Export Function - exportData

function exportData(e, id) {
    var gridid = jQuery(id).getDataIDs(); // Get all the ids in array
    var label = jQuery(id).getRowData(gridid[0]); // Get First row to get the labels
    var mydata = $(id).jqGrid('getGridParam', 'data');
    var obj = new Object();
    obj.count = mydata.length;
    obj.items = new Array();
    for (var i = 0; i < mydata.length; i++) {
        obj.items.push(mydata[i]);
    }
    var json = JSON.stringify(obj);
    JSONToCSVConvertor(json, "csv", 1);
}

// JSON to CSV Converter Function

function JSONToCSVConvertor(JSONData, ReportTitle, ShowLabel) {
    //If JSONData is not an object then JSON.parse will parse the JSON string in an Object
    var arrData = typeof JSONData != 'object' ? JSON.parse(JSONData) : JSONData;
    var CSV = '';
    //This condition will generate the Label/Header
    if (ShowLabel) {
        var row = "";
        //This loop will extract the label from 1st index of on array
        for (var index in arrData.items[0]) {
            //Now convert each value to string and comma-seprated
            row += index + ',';
        }
        row = row.slice(0, -1);
        //append Label row with line break
        CSV += row + '\r\n';
    }
    //1st loop is to extract each row
    for (var i = 0; i < arrData.items.length; i++) {
        var row = "";
        //2nd loop will extract each column and convert it in string comma-seprated
        for (var index in arrData.items[i]) {
            row += '"' + arrData.items[i][index].replace(/(<([^>]+)>)/ig, '') + '",';
        }
        row.slice(0, row.length - 1);
        //add a line break after each row
        CSV += row + '\r\n';
    }
    if (CSV == '') {
        alert("Invalid data");
        return;
    }
    //this trick will generate a temp "a" tag
    var link = document.createElement("a");
    link.id = "lnkDwnldLnk";
    //this part will append the anchor tag and remove it after automatic click
    document.body.appendChild(link);
    var csv = CSV;
    blob = new Blob([csv], { type: 'text/csv' });
    var isIE = false || !!document.documentMode;
    var isEdge = !isIE && !!window.StyleMedia;
    if (isIE) {
        window.navigator.msSaveOrOpenBlob(blob, 'DataName.csv'); // Downloaded File Name Value
    }
    else {
        var myURL = window.URL || window.webkitURL;
        var csvUrl = myURL.createObjectURL(blob);
        var filename = 'DataName.csv'; // Downloaded File Name Value
        jQuery("#lnkDwnldLnk")
                        .attr({
                            'download': filename,
                            'href': csvUrl
                        });
        jQuery('#lnkDwnldLnk')[0].click();
        document.body.removeChild(link);
    }
}

Day 11 - Customizing Option Sets Dropdown Fields with JavaScript

  In this Blog, we will see how to Customizing Option Sets Dropdown Fields with JavaScript label1 = formContext.getAttribute( "bosch_op...