Saturday 17 October 2015

Get the Selected Record Id of Subgrid in CRM 2013/ 2015 - UnSupported

Hi,

At times in CRM, we need to go for unsupported things to fulfill customer requirements. In CRM 2011, we used to get the selected record id of the sub gird in the JavaScript method in a supported way. But in CRM 2013 and 2015 on premise versions we don't have feature available.

Here is the unsupported JavaScript to get the selected record id.

function GetSelectedRecordId() {
    // Grid Control Object
    var objGrid = document.getElementById("opportunityproductsGrid").control;
    // Get Selected Ids.
    var vSelectedIds = objGrid.get_selectedIds();
    if (vSelectedIds.length == 0) {
        alert("No record is selected.");
        return;
    }
    else if (vSelectedIds.length > 1) {
        alert("Please select only one record and click this button.");
        return;
    }
    else {
        // Your logic.
    }
    //All records record id in the sub grid
    // objGrid.get_allRecordIds();
}

Hope this helps.

--
Happy CRM'ing
Gopinath

No comments:

Post a Comment