当前位置:网站首页>Salesforce开发之 如何实现DML操作时,当前用户跳过验证规则(Validation Rule)
Salesforce开发之 如何实现DML操作时,当前用户跳过验证规则(Validation Rule)
2022-08-08 19:01:00 【zcx】
public static void ignoreValidationRules(List<Sobject> dmlList, String dmlType) {
//跳过验证规则
GlobalSetting__c gs;
GlobalSetting__c oldGS;
List<GlobalSetting__c> gsList = [SELECT Id,
SetupOwnerId,
IgnoreValidation__c
FROM GlobalSetting__c
WHERE SetupOwnerId = :UserInfo.getUserId()];
// 设置当前用户忽略验证规则
if (gsList.size() > 0) {
gs = gsList[0];
} else {
gs = new GlobalSetting__c();
gs.SetupOwnerId = UserInfo.getUserId();
}
oldGS = gs.clone();
gs.IgnoreValidation__c = true;
UPSERT gs;
oldGS.Id = gs.Id;
if (dmlType == 'INSERT') {
insert dmlList;
}
if (dmlType == 'UPDATE') {
update dmlList;
}
if (dmlType == 'DELETE') {
delete dmlList;
}
UPDATE oldGS;
}
边栏推荐
- Geometric g6 will carry harmonyos system, a comprehensive upgrade competitiveness of products
- Implement the entire process of Mock API with tools
- hdu2647 N!Again
- run fscript with lua
- El - tree set radio, click finish after assemble
- PX4-做飞控二次开发需要知道的事情-Cxm
- Codeforces Round #712 (Div. 2)(CD)
- Dataworks上的ODPS spark处理数据会比直接用ODPS SQL效率高吗?
- 如何在Firewalld中为特定IP地址开放端口
- 请问shake数据库中mongoshake同步过程中,src_mongo挂了,同步服务不会退出吗?
猜你喜欢
随机推荐
Dandelion R300A 4G router, remote monitoring PLC tutorial
使用 lua 运行 fscript
PG 之 huge page
Redis Server启动过程
用工具实现 Mock API 的整个流程
hdu1042 N! (large number)
The origin and creation of Smobiler's complex controls
即将开幕!阿里云飞天技术峰会邀您一同探秘云原生最佳实践
This error is reported when the shake database is started. Is there a problem with the configuration?
证券开户选哪个券商平台比较好,哪个更安全
企业进行知识共享的好处有哪些?
C语言初阶-结构体
What are the three main aspects of digital factory construction?
Architecture Design Fundamentals
Generate captchas tools
疫情期间闲来无事,我自制了一个按钮展示框特效来展示我的博客
golang for循环详解
分布式文件系统fastDFS
架构设计基本原则
Monaco-Editor Multiplayer Collaboration Editor