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的更多相关文章

  1. 在Salesforce中创建Approval Process

    在Salesforce中可以创建Approval Process来实现审批流程的功能,实际功能与我们常说的Workflow很相似,具体的设置步骤如下所示 1):选择对应的Object去创建对应的App ...

  2. salesforce 零基础开发入门学习(九)Approval Process 介绍

    在阅读此篇文章前,可以先参考阅读一个前辈总结的关于Approval Process的操作.以下为参考的链接: http://www.cnblogs.com/mingmingruyuedlut/p/37 ...

  3. Approval Process 在 Apex 中的使用

    Approval Process(批准过程)简介 批准过程是一个复杂的业务过程.详细的内容可以参考官方文档. 英文版 中文版 官方trailhead模块 在Apex中调用Approval Proces ...

  4. Scoring and Modeling—— Underwriting and Loan Approval Process

    https://www.fdic.gov/regulations/examinations/credit_card/ch8.html Types of Scoring FICO Scores    V ...

  5. salesforce 零基础学习(三十五) 通过Process Builder和Approval Processes锁定记录(Lock Record)

    有的时候我们可能有这样的需求,当某个字段为特定的值情况下,便锁定此条记录,仅允许Profile为System Admin的用户修改或者解锁,其他的用户只能查看此条记录,不能修改此条记录,这种情况下我们 ...

  6. PMP模拟考试-1

    1. A manufacturing project has a schedule performance index (SPI) of 0.89 and a cost performance ind ...

  7. 重邮二进制日天群-pwn1

    给学弟们练手的题目,做的过程中接触一些基本概念 #include <stdio.h> #include <unistd.h> int main() { ]; welcome() ...

  8. Sharepoint学习笔记—习题系列--70-576习题解析 -(Q121-Q123)

    Question  121 You are designing a SharePoint 2010 workflow that will be used to monitor invoices. Th ...

  9. python基础之元组、文件操作、编码、函数、变量

    1.集合set 集合是无序的,不重复的,主要作用: 去重,把一个列表变成集合,就可以自动去重 关系测试,测试两组数据的交集,差集,并集等关系 操作例子如下: list_1 = [1,4,5,7,3,6 ...

随机推荐

  1. Ubuntu紫色背景颜色代码

    前言 我一直很中意Ubuntu的紫,记录一下颜色代码以免忘了! so Ubuntu紫色背景颜色代码background=300924 red = 48 green 9 blue  36

  2. drf基础

    1.什么是编程? 数据结构和算法的结合 2.什么是REST? 同一个功能会产生五花八门的url(把查看单条记录和查看多条记录都看成是一个功能),而且响应回去的数据也没有同一的格式规范,这就造成了前后端 ...

  3. git使用记录九:开发中临时加塞了紧急任务怎么处理

    开发中临时加塞了紧急任务怎么处理 隐藏工作区域 git stash git status 查询隐藏的列表 git stash list 处理完bug,提交之后,再恢复隐藏的工作区域 git stash ...

  4. lua脚本分解字符串

    --local str = "文字45 文字 789 文们adsd45 文字 wowo 文字 文字 wowo我们 wowo456 wiwo 465我们 456sdf 45 45我们adsd4 ...

  5. 前后端分离使用 Token 登录解决方案

    前后端分离使用 Token 登录解决方案:https://juejin.im/post/5b7ea1366fb9a01a0b319612

  6. laravel在路由中设置中间件

    //单个 路由 Route::get( 'admin/admin/index' , [ 'middleware' => 'old', 'uses' => 'Admin\AdminContr ...

  7. linux 服务器,登录出现login incorrect

    1.排查是否是登录用户的密码错误 2.查看本机电脑键盘是否有误 3.排查是否是服务器目录全是777权限 注意事项: 原因是您把系统中全部文件的权限改为的777 ,权限混乱,虽然现在可以访问,但是其他文 ...

  8. SQL优化:一篇文章说清楚Oracle Hint的正确使用姿势

    一.提示(Hint)概述 1为什么引入Hint? Hint是Oracle数据库中很有特色的一个功能,是很多DBA优化中经常采用的一个手段.那为什么Oracle会考虑引入优化器呢?基于代价的优化器是很聪 ...

  9. Linux上用sublime编辑Python时候出现"SyntaxError: Non-ASCII character ‘\xe5′ in file"的问题

    Reopen with Encoding UTF-8也没用,那只是在编辑界面里面显示出中文而已,编译的时候还是不能识别中文. 所以,还是按网上说的吧,在每一个有中文的文件第一行加上# -*- codi ...

  10. 45.Sort List(链表排序)

    Level:   Medium 题目描述: Sort a linked list in O(n log n) time using constant space complexity. Example ...