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. ...
随机推荐
- 从网页上抓取Windows补丁信息然后整型输出(Python)
Powershell实现:http://www.cnblogs.com/IvanChen/p/4488246.html 今天通过Python实现: # coding=utf-8 import re i ...
- 【6集iCore3_ADP触摸屏驱动讲解视频】6-1 工程及程序构架介绍
视频简介: 该视频由银杏科技有限公司基于iCore3应用开发平台推出,包含 触摸屏驱动工程文件的介绍与程序构架的介绍等. 源视频包下载地址: http://pan.baidu.com/s/1dFz ...
- 掌握Thinkphp3.2.0----模版基础
我们将要学习一下 ThinkPHP 模版,ThinkPHP 内置了一个基于 XML 的性能卓越的模版引擎 ThinkTemplate,使用了动态编译和缓存技术,支持自定义标签库, 其实我还体会不到其中 ...
- ECshop通过文章分类的ID实现不同模板
当客户需要想要用不同模板来实现文章页面时,文章就需要实现调用不同模板的内容,着手点就是它的分类ID.直接通过分类ID来判断一下,现在68ecshop技术来告诉你该怎么做 方法如下所示: 一.打开根目录 ...
- Python模拟入栈出栈操作
目标: 1.编写菜单,提示用户操作选项(push,pop,view,quit) 2.规则:定义列表,先入栈,后出栈,后入栈,先出栈 1.模拟入栈.出栈操作 >>> list1 = [ ...
- spark 简介
spark 是基于内存计算的 大数据分布式计算框架,spark基于内存计算,提高了在大数据环境下处理的实时性,同时保证了高容错性和高可伸缩性,允许用户将spark部署在大量廉价的硬件上,形成集群. 1 ...
- linux 监测函数
http://www.ttlsa.com/linux/the-nethogs-view-each-process-uses-bandwidth/ Linux的IO性能监控工具iostat详解 http ...
- python操作word入门
1.安装pywin32 http://sourceforge.net/projects/pywin32 在files里去找适合你的python版本.截止此文,最新版本是pywin32-219快捷路径: ...
- 教你分分钟学会用python爬虫框架Scrapy爬取心目中的女神
本博文将带领你从入门到精通爬虫框架Scrapy,最终具备爬取任何网页的数据的能力.本文以校花网为例进行爬取,校花网:http://www.xiaohuar.com/,让你体验爬取校花的成就感. Scr ...
- SP2-0618: 无法找到会话标识符。启用检查 PLUSTRACE 角色 SP2-0611: 启用 STATISTICS 报告时出错
援引: SP2-0618: 无法找到会话标识符.启用检查 PLUSTRACE 角色 SP2-0611: 启用 STATISTICS 报告时出错 问题描述及解决方法: SQL*Plus: Release ...