crmc.require(['sfdc', 'KendoPopup'], function (sfdc, popup) { crmc.addCustomAction({ "itemID": "createOrdersFromProjects", "isBatchAddItem": true, "isAvailable": function (context) { // This function is called before the action item is displayed and returns a boolean if the item should be displayed // By default determine availability based on Feature Security for this action var isEnabled = this.featureSecurity.getSetting(context.objectDescribe.name, this.itemID) !== false; // Only allow batch adding from Accounts object for now var isOpportunity = context.objectDescribe.name == "Opportunity"; var multipleSelected = context.selectedRows && context.selectedRows.length > 0; return isOpportunity && isEnabled && multipleSelected; }, "getLabel": function (context) { // This function returns the display label of the action item and is called before the item is shown return "Create Billing"; }, "createSubmenuItems": function (context) { // If this function returns additional action item objects, they will appear as submenu items return []; }, "click": function (context) { if(context.selectedRows.length <= 5){ var ids = []; var submitUrl = "/apex/acctseed__BillingFromOpportunity?id=" context.selectedRows.map(function(row) { ids.push(row.Id); }); for (var i = 0; i < ids.length; i++) { window.open(submitUrl + ids[i]); }; } else { popup.popup("Record Selection", "Currently, there is only support for 5 max records per batch."); } } });});