当前位置:网站首页>Salesforce开发之 apex操作批准过程(Approval Process)
Salesforce开发之 apex操作批准过程(Approval Process)
2022-08-08 19:01:00 【zcx】
/*
功能: 对当前记录的审批流程进行自动审批
参数: sobjectID - 要审批的记录Id
comment - 审批意见
rejected - 是否拒绝(True - 拒绝 / False - 通过)
返回: void
*/
public static void autoApprovalOANode(Id sobjectID, String comment, Boolean rejected) {
List<ProcessInstanceWorkitem> pwrList = [SELECT Id
FROM ProcessInstanceWorkitem
WHERE ProcessInstance.TargetObjectId = :sobjectID];
if (pwrList.size() > 0) {
Approval.ProcessWorkitemRequest pwr = new Approval.ProcessWorkitemRequest();
if (rejected) {
pwr.setAction('Reject');
} else {
pwr.setAction('Approve');
}
pwr.setWorkitemId(pwrList[0].Id);
pwr.setComments(comment);
Approval.ProcessResult result = Approval.process(pwr);
if (result.isSuccess()) {
System.debug(LoggingLevel.INFO, '系统自动审批成功!');
} else {
System.debug(LoggingLevel.INFO, '系统自动审批失败!');
}
}
} /*
功能: 当前登录用户是否是记录的当前审批人
参数: sobjectID - 要审批的记录Id
返回: Boolean - True:是 False:不是
*/
public static Boolean currentUserIsApprover(Id sobjectID) {
List<ProcessInstanceWorkitem> pwrList = [SELECT ActorId
FROM ProcessInstanceWorkitem
WHERE ProcessInstance.TargetObjectId = :sobjectID];
if (pwrList.size() > 0 &&
pwrList[0].ActorId == UserInfo.getUserId()) {
return true;
}
return false;
}边栏推荐
- shake数据库中 启动报这个错,请问是哪里配置有问题吗?
- PyTorch入门:(一)数据加载
- 经验分享|低成本快节奏搭建企业知识管理系统的方法
- nyoj714 Card Trick (The 6th Henan Province Programming Contest)
- How is the private key generated by OpenSSH used in putty?
- el-tree设置单选,点击完成后收起
- 启牛商学院开户是安全的吗?开户靠谱吗?
- 我们想更换RDS数据库,从sqlserver 2016 web升级到 2017企业集群版,有专家咨询
- 轻量全景查看器 pannellum初探
- 视图,索引
猜你喜欢

SSM project integration, integrated case

MogDB学习笔记-从0开始

golang流程控制:if分支、switch分支和fallthrough switch穿透

uniapp parent component uses prop to pass asynchronous data to child components

Oracle - table

Open Office XML 格式中的 Style 设计原理

APICloud AVM wraps date and time selection components

el-tree设置单选,点击完成后收起

PG 之 huge page

制造企业为什么要部署数字化工厂系统
随机推荐
laravel 在工作日(节假日除外)运行调度程序命令
十六、一起学习Lua 文件 I/O
Monaco-Editor Multiplayer Collaboration Editor
聚名十周年线上庆典正式开启,发送祝福即有好礼相赠~
计算机网络面试常问知识
Fortinet全新云原生保护产品上线亚马逊云科技平台
Is it safe to open an account with Qiniu Business School?Is it reliable to open an account?
Vue program of web cache problem after packaging
PG's huge page
Excuse me, during the mongoshake synchronization process in the shake database, src_mongo hangs up, will the synchronization service not exit?
nyoj 712 Exploring treasure
Will ODPS spark on Dataworks process data more efficiently than directly using ODPS SQL?
智驾科技完成C1轮融资,此前2轮已融4.5亿元
nyoj 712 探 寻 宝 藏(双线dp 第六届河南省程序设计大赛)
How to add F4 Value Help trial version to the input parameters of the report in the ABAP report
Redis之SDS数据结构
The difference between Redis' memory elimination strategy and expired deletion strategy
shake数据库中 启动报这个错,请问是哪里配置有问题吗?
数据库学习之表的操作
Style Design Principles in Open Office XML Format