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. 小程序 css 文字溢出,长度过长用 。。。

    word-break: break-all;/*允许在单词内换行*/ text-align: left; /* line-height: 45rpx; */ text-overflow: -o-ell ...

  2. 九. jenkins用户权限管理

    由于jenkins默认的权限管理体系不支持用户组和角色的配置,所以需要使用第三方插件来支持角色的配置: Role-based Authorization Strategy 1.先安装插件,如下: 2. ...

  3. 三种数据库截取字段内容&&获取字符长度的函数如下

    if(databaseutil.getValue("database").equalsIgnoreCase("sqlserver")){ list =categ ...

  4. 【转】Selenium 加载Chrome/Firefox浏览器配置文件

    原文地址:https://www.cnblogs.com/eastonliu/p/9083982.html Selenium启动浏览器时,默认是打开一个新用户,不会加载原有的配置以及插件.但有些时候我 ...

  5. Centos 7.3 配置Xmanager XDMCP

    我们通常需要远程桌面,这会带来很好的便利性,而Centos7的XDMCP配置过程发生了变化,添加了很多新特性,初期难免会不适应,但新系统终究还是不错的.下面看看Centos7下如何配置XManager ...

  6. [Vue warn]: Avoid mutating a prop directly since the value will be overwritten whenever the parent component re-renders. Instead, use a data or computed property based on the prop's value. Prop being

    [Vue warn]: Avoid mutating a prop directly since the value will be overwritten whenever the parent c ...

  7. win10 命令重置 管理员密码

    重置win10系统管理员的方法有不少,这里给大家介绍的一种用Windows PowerShell命令重置win10管理员密码方法教程,感兴趣的用户,可以学习一下. 操作过程: 1.点击左下角的开始菜单 ...

  8. PostgreSQL 荣获 2019 年 O'Reilly 终身成就奖

    Java技术栈 www.javastack.cn 优秀的Java技术公众号 来自:开源中国社区 https://www.oschina.net/news/108436/pg-wins-2019-ore ...

  9. Scrapy框架: 通用爬虫之SitemapSpider

    步骤01: 创建项目 scrapy startproject cnblogs 步骤02: 编写items.py # -*- coding: utf-8 -*- # Define here the mo ...

  10. 网关中加入熔断机制(Hystrix)

    网关中加入熔断机制 在网关中加入熔断机制 添加依赖项 spring-cloud-gateway项目POM文件加入spring-cloud-starter-netflix-hystrix <dep ...