// {!REQUIRESCRIPT('https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js')} // jQuery.noConflict();// (function($, buttonObj) {// var pageName = "BillingBatchUnpost";// var disabledLabel = "Unposting...";// var packageName = (buttonObj.name.indexOf("acctseed") >= 0 ? "acctseed__" : "");// var submitUrl = "{!URLFOR('/apex/" + packageName + pageName + "')}";// if (buttonObj.name.indexOf("acctseed") >= 0) {submitUrl = submitUrl.replace("--c","--acctseed").replace("//c","//acctseed");}// var submitForm = buttonObj.form;// submitForm.action = submitUrl + "?retURL=" + encodeURIComponent(location.pathname + location.search) + "&wrapMassAction=1&scontrolCaching=1";// submitForm.onsubmit = function() { return true }; // $(".listButtons .btn").not(".refreshListButton").toggleClass("btnDisabled").val(disabledLabel).prop("disabled", true);// submitForm.submit();// })(jQuery,this);crmc.require(['sfdc', 'KendoPopup'], function (sfdc, popup) { crmc.addCustomAction({ "itemID": "Batch_UnPost_Billings_From_Billings", "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 isProject = context.objectDescribe.name == "AcctSeed__Billing__c"; var multipleSelected = context.selectedRows && context.selectedRows.length > 0; return isProject && isEnabled && multipleSelected; }, "getLabel": function (context) { // This function returns the display label of the action item and is called before the item is shown return "UnPost Billings"; }, "createSubmenuItems": function (context) { // If this function returns additional action item objects, they will appear as submenu items return []; }, "click": function (context) { // Include static resource from managed namespace pre-creates session and allows us to safely POST data without redirect issue var head = document.getElementsByTagName('HEAD').item(0); var script = document.createElement("script"); script.type = "text/javascript"; head.appendChild(script); var domains = window.location.hostname.split("."); if (domains.length == 3) { instance = domains[0]; } else { instance = domains[1]; } script.src = "https://AcctSeed." + instance + ".visual.force.com/resource/AcctSeed__ButtonJSFunctions?ts=" + new Date().getTime(); script.onerror = function() { // Couldn't load app script, assume not installed popup.popup("Could not obtain session for Accounting Seed Financial Suite is the app installed?"); }; script.onload = function() { if (context.selectedRows.length > 0) { var selectedIds = []; Object.each(context.selectedRows, function (item) { selectedIds.push({name: "ids", value: item["Id"]}); }); var parameters = { retURL: context.actionGrid.settings.pageURL, }; sfdc.postToVFPage("acctseed", "BillingBatchUnpost", parameters, selectedIds); } else { popup.popup('Please select records', 'Select at least one record to unpost Billings.'); } }; } });});