How to add Custom Call out in SharePoint Online/Office 365?

Hello SharePointers,

The call out in document library will let you to do share , edit or follow the specific item. In case, if you want to do your custom call out functionality such as adding a new button and opening up a new URL . Her is the source code to achieve the same.

<head>

<script language=”javascript” type=”text/javascript”>
SP.SOD.executeFunc(“Callout.js”, “Callout”, function () {
var itemCtx = {};
itemCtx.Templates = {};
itemCtx.BaseViewID = ‘Callout’;
// Define the list template type
itemCtx.ListTemplateType = 101;
itemCtx.Templates.Footer = function (itemCtx) {
// context, custom action function, show the ECB menu (boolean)
return CalloutRenderFooterTemplate(itemCtx, AddCustomAction, true);
};
SPClientTemplates.TemplateManager.RegisterTemplateOverrides(itemCtx);
});

function AddCustomAction (renderCtx, calloutActionMenu) {
// Add your custom action
calloutActionMenu.addAction (new CalloutAction ({
text: “Approve”,
tooltip: ‘Approve your reconciliation here’,
onClickCallback: function() {
var itemIndex = renderCtx.CurrentItemIdx;
console.log(‘Callback from custom action’);
var editPropUrl = renderCtx.CurrentItem.FileRef;
var preUrl = _spPageContextInfo.siteAbsoluteUrl;

window.location.href = preUrl+”/”+”ProductionLibrary/Forms/EditForm.aspx?ID=”+renderCtx.CurrentItem.ID;
var itemId =renderCtx.CurrentItem.ID;

}
}));
}

</script>

 

Happy SharePointing Folks 🙂

Leave a Reply

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