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. ...
随机推荐
- Apache Flink初接触
Apache Flink闻名已久,一直没有亲自尝试一把,这两天看了文档,发现在real-time streaming方面,Flink提供了更多高阶的实用函数. 用Apache Flink实现WordC ...
- phpv6_css
global @charset "utf-8"; /* CSS Document */ /*格式化样式*/ body,div,dl,dt,dd,ul,ol,li,h1,h2,h3, ...
- iOS移动硬盘实现原理
iOS移动硬盘,仅仅是一个概念的包装,原理是在用户目录下创建一个特定的目录,应用层做一个界面直接访问这个目录而已. 大概流程是: 监听获得device句柄. AMDeviceConnect连接设备,并 ...
- python thrift 服务端与客户端使用
一.简介 thrift是一个软件框架,用来进行可扩展且跨语言的服务的开发.它结合了功能强大的软件堆栈和代码生成引擎,以构建在 C++, Java, Python, PHP, Ruby, Erlang, ...
- Arduino.h
#ifndef Arduino_h #define Arduino_h #include <stdlib.h> #include <stdbool.h> #include &l ...
- 接口测试之基于LoadRunner的一个简单示例
这几天一直在捣鼓接口测试,以下总结一下: 1.什么是接口测试:接口是指系统模块与模块之间或者系统与系统之间进行交互,一般我们用的多的是HTTP协议的接口.WebService协议的接口.还有RPC(R ...
- GIT-查看本地html帮助文档
GIT安装后可以直接在命令行中通过指令调取本地html帮助文档如下所示: 格式: git help remote--git help 指令名称 git help remote 显示结果 获取branc ...
- VS2013中使用git发布解决方案master分支的时候出现错误
VS2013GIT基础用法请自行参考:不会Git命令,照样玩转Git 环境:VS2013+ 码云错误描述:在VS2013中使用git发布解决方案master分支的时候出现“无法将本地分支 master ...
- web app上传图片
很就很久以前,web app上传图片需要通过cordova插件,那时候好像还叫phonegap. 后来一个html标签就可以了 <input type="file" clas ...
- Union和Union All到底有什么区别
以前一直不知道Union和Union All到底有什么区别,今天来好好的研究一下,网上查到的结果是下面这个样子,可是还是不是很理解,下面将自己亲自验证: Union:对两个结果集进行并集操作,不包括重 ...