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:
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); } |