salesforce获取RecordTypeId的两种方法
来源:互联网 发布:网络侵权的管辖 编辑:程序博客网 时间:2024/06/06 01:40
应用场景:在使用Apex新建记录时,有时需要根据具体需求为用户匹配对应的记录类型,这个时候就需要用到记录类型Id的情况。
获取RecordTypeId的方法有2种,一种是根据soql进行查询,另一种是使用内置方法查询;
方法1:过滤的是DeveloperName
Id recordTypeId = [SELECT Id, Name, DeveloperName, isActive FROM RecordType WHERE DeveloperName ='Tender_Record_Offline_Media' AND SobjectType = 'Advertiser_Tender_Relationship__c' LIMIT 1].Id方法2:注意传入的是Label Name
Id devRecordTypeId = Schema.SObjectType.ObjectName.getRecordTypeInfosByName().get('Label Name').getRecordTypeId();
如:Id devRecordTypeId = Schema.SObjectType.Advertiser_Tender_Relationship__c.getRecordTypeInfosByName().get('线下媒介-普通').getRecordTypeId();
相关截图:
资源链接:
https://devforce.co/apex-tip-how-to-get-a-recordtype-id-by-name-without-soql/
https://salesforce.stackexchange.com/questions/157608/getrecordtypeinfosbyname
阅读全文
1 0
- salesforce获取RecordTypeId的两种方法
- 两种salesforce中展示图片的解决方案
- 两种获取Oracle Sequence的方法
- 获取rowid的两种方法。
- 获取文件目录的两种方法
- 获取设备句柄的两种方法
- jsf 获取表单的两种方法
- 获取interface的两种方法
- android 获取Bitmap 的两种方法
- 获取手机屏幕大小的两种方法
- 获取文件目录的两种方法
- jmx获取MBeanServerConnection的两种方法
- 两种获取灰度图像的方法
- 获取mac地址的两种方法
- 获取当前时间的两种方法
- 两种获取Oracle Sequence的方法
- 获取当前数据库的两种方法
- android 获取Bitmap 的两种方法
- Linux添加/删除用户和用户组
- C语言——实例039 有一个已经排好序的数组。现输入一个数,要求按原来的规律将它插入数组中
- 安装 pyspider ConfigurationError: Could not run curl-config: [Errno 2] No such file or directory
- HTML标签
- div中的文字上下左右居中的方法
- salesforce获取RecordTypeId的两种方法
- 51nod 1119 机器人走方格 V2 费马小定理求组合数
- Unreal Engine4 初学第一天
- 中国剩余定理 Biorhythms HDU
- 传值调用、传址调用
- CodeForces
- 事务是什么,以及事务四个特性
- sizeof()为什么不能得到指针指向内容的大小
- 【HDU】1241--Oil Deposits(DFS)