Create New Entity from related entity via Ribbon – CRM 2013 & CRM 2015

The fastest way to create a new child record for the current entity using a custom ribbon button, is the following approach:

Pass the following parameters to your custom javascript function called CreateNewCRMEntity (for example), as shown in the below image:

ribbon

The next step is to use the following code:

function CreateNewCRMEntity(selectedentitytypecode, primaryentitytypecode, firstprimaritemid, PrimaryControl, SelectedControl) 
{
    var selectedentitytypecode = 10204; // override the passed parameter with your entity etc (object type code)
    Xrm.Page.data.entity.save();
    Mscrm.GridRibbonActions.addNewFromSubGridStandard(selectedentitytypecode, primaryentitytypecode, firstprimaritemid, PrimaryControl, SelectedControl);
}

Leave a comment

Your email address will not be published. Required fields are marked *