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

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s