应用场景:在使用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. 常见报错——Uncaught TypeError: document.getElementsByClassName(...).addEventListener is not a function

    这是因为选择器没有正确选择元素对象 document.getElementsByClassName(...)捕捉到的是该类名元素的数组 正确的访问方式应该是: document.getElements ...

  2. Python_基础_Print_输出函数

    输出函数print() print()函数: 功能:向目的地输出内容 输出的内容:数字.字符串.表达式 目的地:IDLE.控制台.文件 print()函数可以输出些什么内容? 数字 字符串(用单引号和 ...

  3. Golang(vs code) 调用其他自定义包解决方法

    初学Golang,昨天遇到一个问题:调用其他自定义包,会出现Gopath或者Goroot路径下找不到. 举个例子: 如图Gee文件夹下的三个.go 文件就是我main.go想调用的. 我有尝试过这种方 ...

  4. koa获取get和post的参数实例代码

    1 const Koa = require('koa'); 2 const Router = require('koa-router');//引用koa-router 3 const KoaBody ...

  5. 基于注解的AOP

    1.引入依赖 <!--spring aop依赖--> <dependency> <groupId>org.springframework</groupId&g ...

  6. webpack4从0开始构建前端单页项目(15)用clean-webpack-plugin清理构建前的目录(dist)

    clean-webpack-plugin 这个插件用来清空打包后的 dist 目录下的文件.可以避免每次打包前手动删除构建目录(dist)下的文件. 安装 clean-webpack-plugin c ...

  7. 【服务器数据恢复】ZFS文件系统下ZPOOL下线的数据恢复案例

    服务器数据恢复环境:SUN ZFS系列某型号存储阵列:40块磁盘组建的存储池(其中4块磁盘用作全局热备盘),池内划分出若干空间映射到服务器使用:服务器使用Windows操作系统. 服务器故障:服务器在 ...

  8. (Python)email 邮件发送

    """ 1. 发送邮件的几个步骤: 1)与邮件服务器建立会话连接 2)指定用户的登录 3)发送邮件 2. 一个标准邮件包含: 1)邮件头:标题:收件人.发送人.抄送cc. ...

  9. pip python的包成功,但是import的时候报错

    今天,一位同学线上反馈import python包失败了,同时附带两张图: 图1.报错代码 图2.报错提示 结合上面两个图片,我们发现这个同学import全部失败,初步怀疑该同学的本地环境上没有num ...

  10. 搭建ftp服务器的超详细步骤

    第一步:打开控制面板. 1.1选择程序这个选项. 1.2选择启用或关闭window功能 1.3勾选如图有红箭头的这几个选项. 第二步:搜索iis且将其打开 . 2.1点击网站,且点击添加网站 物理路径 ...