66、saleforce 的 approval process
public class TestApproval {
public void submitAndProcessApprovalRequest() {
// Insert an account
Line_Item__c a = new Line_Item__c();
a.Name = 'Test_Line_Item_code_approval';
a.Quantity__c =2;
a.Unit_Price2__c =1200;
Merchandise__c merchan = new Merchandise__c();
merchan.Name ='Test_merchandise_code_approval';
merchan.Quantity__c = 100;
merchan.Price__c = 20000;
insert merchan;
a.Merchandise__c = merchan.Id;
Invoice__c invo = new Invoice__c();
invo.Status__c ='Open';
insert invo;
a.Invoice__c = invo.Id;
insert a;
User user1 = [SELECT Id FROM User WHERE Alias='weizh'];
// Create an approval request for the account
Approval.ProcessSubmitRequest req1 = new Approval.ProcessSubmitRequest();
req1.setComments('Submitting request for approval.');
req1.setObjectId(a.id);
// Submit on behalf of a specific submitter
req1.setSubmitterId(user1.Id);
ID[] ids = new ID[]{user1.Id};
req1.setNextApproverIds(ids);
// Submit the record to specific process and skip the criteria evaluation
//req1.setProcessDefinitionNameOrId('PTO_Request_Process');
req1.setSkipEntryCriteria(true); // Submit the approval request for the account
Approval.ProcessResult result = Approval.process(req1); // Verify the result
System.assert(result.isSuccess());
System.assertEquals( 'Pending', result.getInstanceStatus(), 'Instance Status'+result.getInstanceStatus());
// Approve the submitted request
// First, get the ID of the newly created item
List<Id> newWorkItemIds = result.getNewWorkitemIds();
// Instantiate the new ProcessWorkitemRequest object and populate it
Approval.ProcessWorkitemRequest req2 = new Approval.ProcessWorkitemRequest();
req2.setComments('Approving request.');
req2.setAction('Approve');
req2.setNextApproverIds(new Id[] {UserInfo.getUserId()});
// Use the ID from the newly created item to specify the item to be worked
req2.setWorkitemId(newWorkItemIds.get(0));
// Submit the request for approval
Approval.ProcessResult result2 = Approval.process(req2);
// Verify the results
System.assert(result2.isSuccess(), 'Result Status:'+result2.isSuccess());
System.assertEquals( 'Approved', result2.getInstanceStatus(), 'Instance Status'+result2.getInstanceStatus());
}
}
66、saleforce 的 approval process的更多相关文章
- 在Salesforce中创建Approval Process
在Salesforce中可以创建Approval Process来实现审批流程的功能,实际功能与我们常说的Workflow很相似,具体的设置步骤如下所示 1):选择对应的Object去创建对应的App ...
- salesforce 零基础开发入门学习(九)Approval Process 介绍
在阅读此篇文章前,可以先参考阅读一个前辈总结的关于Approval Process的操作.以下为参考的链接: http://www.cnblogs.com/mingmingruyuedlut/p/37 ...
- Approval Process 在 Apex 中的使用
Approval Process(批准过程)简介 批准过程是一个复杂的业务过程.详细的内容可以参考官方文档. 英文版 中文版 官方trailhead模块 在Apex中调用Approval Proces ...
- Scoring and Modeling—— Underwriting and Loan Approval Process
https://www.fdic.gov/regulations/examinations/credit_card/ch8.html Types of Scoring FICO Scores V ...
- salesforce 零基础学习(三十五) 通过Process Builder和Approval Processes锁定记录(Lock Record)
有的时候我们可能有这样的需求,当某个字段为特定的值情况下,便锁定此条记录,仅允许Profile为System Admin的用户修改或者解锁,其他的用户只能查看此条记录,不能修改此条记录,这种情况下我们 ...
- PMP模拟考试-1
1. A manufacturing project has a schedule performance index (SPI) of 0.89 and a cost performance ind ...
- 重邮二进制日天群-pwn1
给学弟们练手的题目,做的过程中接触一些基本概念 #include <stdio.h> #include <unistd.h> int main() { ]; welcome() ...
- Sharepoint学习笔记—习题系列--70-576习题解析 -(Q121-Q123)
Question 121 You are designing a SharePoint 2010 workflow that will be used to monitor invoices. Th ...
- python基础之元组、文件操作、编码、函数、变量
1.集合set 集合是无序的,不重复的,主要作用: 去重,把一个列表变成集合,就可以自动去重 关系测试,测试两组数据的交集,差集,并集等关系 操作例子如下: list_1 = [1,4,5,7,3,6 ...
随机推荐
- JS获取浏览器地址栏的多参数值的任意值
常用的几个方法就不讲了,这里我用的是两个方法组 使用方法是: getParamValue("id"); http://localhost:2426/TransactionNotes ...
- MySQL清除表数据而保留表结构TRUNCATE TABLE
有时候我们会需要清除一个表格中的所有资料.要达到者个目的,一种方式是使用 DROP TABLE 指令,不过这样整个表格就消失,表无法再被用了.另一种方式就是运用 TRUNCATE TABLE 的指令. ...
- 封装token
let baseApiUrl = 'xxxx' var app = getApp(); let defaultHeaders = { 'Content-Type': 'application/json ...
- Webshell免杀
过狗过D盾 <?php class me{ public $a = ''; function __destruct(){ assert("$this->a"); }}$ ...
- CSDN如何转载别人的博客
前言 对于喜欢逛CSDN的人来说,看别人的博客确实能够对自己有不小的提高,有时候看到特别好的博客想转载下载,但是不能一个字一个字的敲了,这时候我们就想快速转载别人的博客,把别人的博客移到自己的空间 ...
- Redis 系列(04-2)Redis原理 - 内存回收
目录 Redis 系列(04-2)Redis原理 - 内存回收 Redis 系列目录 1. 过期策略 1.1 定时过期(主动淘汰) 1.2 惰性过期(被动淘汰) 1.3 定期过期 2. 淘汰策略 2. ...
- 用vim写go代码——vim-go插件
GoImport:导入包 GoImport!:导入远程包 GoImportAs: 导入包并且重命名
- 【Python—字典的用法】找到多个字典的公共键
有 a,b,c,d,e,f 6名球员,他们在三轮比赛中的进球数用 s1,s2,s3 3个字典表示,找到每轮都有进球的球员? 创建 s1,s2,s3 3个字典素材 from random import ...
- P1001 A+B Problem
下面我们要展示这个题的玄学做法!!!@cjx!!! #include<iostream> #define chen using namespace std; #define jia int ...
- MVC的实体模型写在类库,为什么被其他类库调用时,用不了模型的表?
一,很简单,由于第一次添加实体模型时,VS会自动帮你添加引用System.Data.Entity到当前类库,如下图示: 二,而手动添加的类库并不存在这个引用,则及时你引用了当前的实体模型的类库,却使用 ...