005_重写 Standard Delete Button
{!REQUIRESCRIPT("/soap/ajax/32.0/connection.js")}
{!REQUIRESCRIPT("/soap/ajax/32.0/apex.js")}
var record = new sforce.SObject("Opportunity");
record.Id = '{!Opportunity.Id}';
//copy opportunity line items
result = sforce.connection.query("Select PricebookEntry.Product2.Name, Quantity, TotalPrice From OpportunityLineItem WHERE OpportunityId = '{!Opportunity.Id}' and (NOT Name like '%Discount%')");
records = result.getArray("records");
var strProductNames = '';
for(var i=0; i<records.length ; i++){
strProductNames += 'PRODUCT NAME: ' + records[i].PricebookEntry.Product2.Name + ' --- QUANTITY: ' + records[i].Quantity + ' --- TOTAL PRICE: $ ' + records[i].TotalPrice +',\n';
}
if(strProductNames.length>0){
strProductNames = strProductNames.substring(0,strProductNames.length-2);
}
record.Samples_Sent__c = strProductNames;
//delete opportunity line items
var lineItems = sforce.connection.query("select id from opportunitylineitem where opportunityid = '{!Opportunity.Id}'")
var oliIds = []
var qri = new sforce.QueryResultIterator(lineItems)
while(qri.hasNext())
oliIds.push(qri.next().Id)
sforce.connection.deleteIds(oliIds)
sforce.connection.update([record]);
window.location.reload();
-------------------------------------------------------------------以下的方法是以传统的,适用于较多的业务逻辑的方式。页面->Controller
以后会用JS直接删除,但是在加载.js时候出现问题,会在以后进一步追踪完善:
<apex:page standardController="Opportunity" >
<!--extensions="accountDelete" action="{!deleterecord}"-->
<script type="text/javascript">
var __sfdcSessionId = '{!GETSESSIONID()}';
</script>
<script src="../../soap/ajax/35.0/connection.js" type="text/javascript"></script>
<script type="text/javascript">
window.onload = setupPage;
function setupPage() {
if('{!Opportunity.Name}'=='ddd33'){
alert('{!Opportunity.Name}');
window.top.location = '/' + '{!Opportunity.Id}';
} else{
sforce.connection.deleteIds('{!Opportunity.Id}');
alert('123456');
window.top.location = '/' + '001/o'; }
}
</script>
</apex:page>
——————————————————————————————————————————————————————————
<apex:page standardController="Account" extensions="accountDelete" action="{!deleterecord}">
<apex:pageMessages />
</apex:page>
public with sharing class accountDelete {
apexpages.standardcontroller controller;
public accountDelete(ApexPages.StandardController controller) {
this.controller = controller;
}
public pagereference deleteRecord() {
try {
delete controller.getRecord();
return new pagereference('/home/home.jsp'); //return new pagereference('/001/o'); ----------执行完controller 后跳转到的页面;
} catch(exception e) {
apexpages.addmessages(e);
}
return null;
}
}
005_重写 Standard Delete Button的更多相关文章
- UITableViewCell delete button 上有其它覆盖层
第一种解决办法: // Fix for iOS7, when backgroundView comes above "delete" button - (void)willTran ...
- ui-select : There is no "X"(delete button) with selectize theme, when allow-clear="true"
but add allow-clear="true"For Bootstrap and Select2 themes, it's working perfectly. reason ...
- 在Salesforce中可以对某一个Object的Standard Button或Link进行重写
在Salesforce中可以对某一个Object的Standard Button或Link进行重写,来实现我们特定的逻辑过程,比如:在删除某个Object之前要判断该Object的某个Field的状态 ...
- [salesforce] standard button
Use Case In Salesforce, when you click on the standard ‘New’ button on a Related List to create a ne ...
- C++重写new和delete,比想像中困难
关于C++内存管理这话题,永远都不过时.在我刚出道的时候,就已经在考虑怎么检测内存泄漏(https://www.cnblogs.com/coding-my-life/p/3985164.html).想 ...
- iphone dev 入门实例3:Delete a Row from UITableView
How To Delete a Row from UITableView I hope you have a better understanding about Model-View-Control ...
- 【50】了解new和delete的合理替换时机
1.有时候,我们替换掉编译器提供的new或者delete.首先思考,为什么想要替换?下面是三个常见理由: a.用来检测运用上的错误,超额分配一些内存,再额外的空间放置一些内存: b.为了强化效能,编译 ...
- new/delete工作机制
body, table{font-family: 微软雅黑; font-size: 10pt} table{border-collapse: collapse; border: solid gray; ...
- [Nuxt] Use Vuex Actions to Delete Data from APIs in Nuxt and Vue.js
You'll begin to notice as you build out your actions in Vuex, many of them will look quite similar. ...
随机推荐
- VirtualBox + CentOS 使用 NAT + Host-Only 方式联网
之前一直使用 VMware 作为虚拟机,这几天看<跟阿铭学Linux>,里面用的是虚拟机是 Oracle VirtualBox,也跟着安装配置一个,但是比较坑的是照着上面的配置折腾了很久才 ...
- REACT day 1
https://facebook.github.io/react/ A JAVASCRIPT LIBRARY FOR BUILDING USER INTERFACES Declarative view ...
- java swing文件内容检索工具
Java相关技术 - 文件内容检索工具 拿到一个几百M甚至上G的project让你去学习 有时候你会想知道某个关键词是在哪个文件里 比如:spring MVC配置的@RequestMapping,你从 ...
- Java Basic Exception
异常处理经验小结之一:不要直接抛出InvocationTargetException (转http://olylakers.iteye.com/blog/1137371) 在最近一段时间的工作中,积 ...
- Source Insight 3.X utf8支持插件震撼发布
继上次SI多标签插件之后,因为公司内部编码改为utf8编码,因此特意做了这个Source Insight 3.X utf8插件. 下载地址:[点我] 安装说明: 解压msimg32.dll sihoo ...
- centos6.7下安装mvn 、安装elasticsearch下ik分词
先说一下安装mvn步骤,如果已安装可以忽略: 在tmp目录下 1.建立mvn目录 mkdir mvn cd /tmp/mvn 2.下载 wget http://apache.fayea.com/mav ...
- spark-submit 分发应用
Spark 提供了一个名为spark-submit 的单一工具来跨集群管理器的提交作业,命令如下: bin/spark-submit [options] <app jar | python fi ...
- 【vue.js权威指南】读书笔记(第一章)
最近在读新书<vue.js权威指南>,一边读,一边把笔记整理下来,方便自己以后温故知新,也希望能把自己的读书心得分享给大家. [第1章:遇见vue.js] vue.js是什么? vue.j ...
- SQL Server 不清空数据,修改数据库字段、结构,阻止保存要求重新创建表的更改
当数据库有数据修改数据库字段时,默认是阻止的! 工具---选项---设计器---阻止保存要求重新创建表的更改(取消钩)
- 使用Flexible适配移动端html页面 - demo记录
前段时间看了大神的博客文章[使用Flexible实现手淘H5页面的终端适配](地址:http://www.w3cplus.com/mobile/lib-flexible-for-html5-layou ...