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. Python笔记(八)_内部函数与闭包

    内部函数 在函数内部定义另一个函数,也就是函数的嵌套 在外部函数的作用域内,外部函数可以随意调用内部函数 由于内部函数的整个定义过程都在外部函数中,所以出了外部函数就无法再被调用了 def outsi ...

  2. spring data jpa Specification动态查询

    package com.ytkj.entity; import javax.persistence.*; import java.io.Serializable; /** * @Entity * 作用 ...

  3. for语句和if语句画正方形菱形

    public static void main(String[] args) { int n =8; // 空心正方形 for(int i=0;i<=n;i++){ if(i==0||i==n) ...

  4. vue (UI)

  5. 偏向锁,偏向线程id ,自旋锁

    理解锁的基础知识 如果想要透彻的理解Java锁的来龙去脉,需要先了解以下基础知识. 基础知识之一:锁的类型 锁从宏观上分类,分为悲观锁与乐观锁. 乐观锁 乐观锁是一种乐观思想,即认为读多写少,遇到并发 ...

  6. 网站设置成代理后,chrome chrome HTTP ERROR 502

    在阿里云上设置CNAME代理后,发现www.xxxx.com出现502,但是http://xxxx.com却可以访问. ping了一下都可以,网上搜了搜原来和nginx.conf配置有关 配置如下,上 ...

  7. Python做个小游戏

    Ps.可去知乎搜索“雨露浅歌”大神,他写的帖子里有详细讲解和源码. 游戏概述.玩法:通过键盘的↑键来控制小球往上走,当松开↑键时,小球以一定速度向下掉,小球每越过一根棒加1000分,越过一个飞镖加20 ...

  8. 在Ubuntu custom kernel上裝perf by compile

    Using perf, the Linux Performance Analysis tool on Ubuntu Karmic A lot has been going on with Linux ...

  9. UVA 12672 Eleven(DP)

    12672 - Eleven Time limit: 5.000 seconds In this problem, we refer to the digits of a positive integ ...

  10. RabbitMq--3--案例

      https://blog.csdn.net/hellozpc/article/details/81436980