应用场景:在使用Apex新建记录时,有时需要根据具体需求为用户匹配对应的记录类型,这个时候就需要用到记录类型Id的情况。

获取RecordTypeId的方法有2种,一种是根据soql进行查询,另一种是使用内置方法查询;

方法1:过滤的是DeveloperName

  1. Id recordTypeId = [SELECT Id, Name, DeveloperName, isActive
  2. FROM RecordType
  3. WHERE DeveloperName ='Tender_Record_Offline_Media' AND SobjectType = 'Advertiser_Tender_Relationship__c' LIMIT 1].Id

方法2:注意传入的是Label Name

  1. Id devRecordTypeId = Schema.SObjectType.ObjectName.getRecordTypeInfosByName().get('Label Name').getRecordTypeId();
  1. 如: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

041_Record Type的更多相关文章

  1. salesforce 零基础学习(六十二)获取sObject中类型为Picklist的field values(含record type)

    本篇引用以下三个链接: http://www.tgerm.com/2012/01/recordtype-specific-picklist-values.html?m=1 https://github ...

  2. AutoMapper:Unmapped members were found. Review the types and members below. Add a custom mapping expression, ignore, add a custom resolver, or modify the source/destination type

    异常处理汇总-后端系列 http://www.cnblogs.com/dunitian/p/4523006.html 应用场景:ViewModel==>Mode映射的时候出错 AutoMappe ...

  3. $.type 怎么精确判断对象类型的 --(源码学习2)

    目标:  var a = [1,2,3];     console.log(typeof a); //->object     console.log($.type(a)); //->ar ...

  4. input type='file'上传控件假样式

    采用bootstrap框架样式 <!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> &l ...

  5. mount报错: you must specify the filesystem type

    在linux mount /dev/vdb 到 /home 分区时报错: # mount /dev/vdb /homemount: you must specify the filesystem ty ...

  6. error C4430:missing type specifier 解决错误

    错误    3    error C4430: missing type specifier - int assumed. Note: C++ does not support default-int ...

  7. The type javax.ws.rs.core.MediaType cannot be resolved. It is indirectly referenced from required .class files

    看到了http://stackoverflow.com/questions/5547162/eclipse-error-indirectly-referenced-from-required-clas ...

  8. OpenCASCADE Ring Type Spring Modeling

    OpenCASCADE Ring Type Spring Modeling eryar@163.com Abstract. The general method to directly create ...

  9. <input type="file">上传文件并添加路径到数据库

    注:这里是用的mvc所以没法用控件 html代码 <form method="post" enctype="multipart/form-data"> ...

  10. html中,文件上传时使用的<input type="file">的样式自定义

    Web页面中,在需要上传文件时基本都会用到<input type="file">元素,它的默认样式: chrome下: IE下: 不管是上面哪种,样式都比较简单,和很多 ...

随机推荐

  1. Biba模型(MAC)

    毕巴模型用完整性级别来对完整性进行量化描述. 设i­1和i2是任意两个完整性级别,如果完整性级别为i2的实体比完整性级别为i1的实体具有更高的完整性,则称完整性级别i2绝对支配完整性级别i1,记为:i ...

  2. Request processing failed;

    用 ssm 框架修改数据库数据时,出现了 Request processing failed; nested exception is org.mybatis.spring.MyBatisSystem ...

  3. Delphi模拟win+tab按键效果

    //按下左侧win键 keybd_event(VK_LWIN,0,0,0); //按下tab键 keybd_event(VK_TAB,0,0,0); //抬起左侧win键 keybd_event(VK ...

  4. 小白之Linux基础命令

    命令大全 : http://man.linuxde.net/touch --------------------------20170802晚linux ls--显示当前路径下的文件及文件夹名字cd ...

  5. 快速上手SpringBoot

    快速上手SpringBoot SpringBoot是用来简化Spring应用的初始化搭建以及开发过程 三个不需要,这是springboot使用mvc区别于其它框架的特点 tomcatd的端口 下一行是 ...

  6. hive元起动报错:Exception in thread "main" java.lang.NoSuchMethodError: com.google.common.base.Preconditions.checkArgument(ZLjava/lang/String;Ljava/lang/Object;)V

    错误原因: 1.系统找不到这个类所在的jar包 2.jar包的版本不一样系统不知道使用哪个. hive启动报错的原因是后者 解决办法: 1.com.google.common.base.Precond ...

  7. word文件打开报错:abnormal program termination

    部分word文件打开后报错 处理方法 1.更改默认打印机 2.调整开机启动项 取消该项:cyberkI guard service的开机自启动 (赛博昆仑安全软件) 3.调整word的COM加载项

  8. Winfrom ComboBox中的性能探索

    在为Control维护元素列表的过程中,会不可避免的造成性能损耗,我们接下来要探究的就是哪种方式才是我们的最优解. 方案比较 以ComboBox为例,常见的方式一共有两种:Add.AddRange. ...

  9. selenium爬取PDF预览文件

    python selenium 爬取某网站的pdf预览文件,下载图片转换pdf 参考链接:https://blog.csdn.net/weixin_44740756/article/details/1 ...

  10. vs输出重定向

    1.右键点击解决工程->项目属性 2.配置属性->生成事件->生成后事件 在命令行中输入:"$(TargetPath)  >$(outdir)\1.txt" ...