应用场景:在使用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. angular 路由守卫Observable异步请求串联

    假设路由守卫有这种场景 需要使用observable同时发送多个Http 请求,判断request2返回的数据中是否存在request1返回的数据 使用async await export class ...

  2. VS2022在打开设计器的时候提示某变量未声明或者未赋值

    有可能是在属性中直接添加引用的dll文件,导致dll并不能被该文件稳定引用,可以删除引用,重新添加试试

  3. js判断图片链接是否有效

    let checkImgExists = function(url) { return new Promise(function(resolve, reject) { let ImgObj = new ...

  4. react 二级路由嵌套

    嵌套路由之后,静态文静路径错误, 更改webpack  打包output 输出根目录,publicPath:'/',二级路由刷新之后白屏,在首页模板文件中路径前加   /,

  5. Excel VBA实例

    有个朋友让帮忙看下excel数据怎么处理,初步一看有点复杂,难以下手.进一步分析.搜索,发现VBA可以很好地解决这个问题,总结记录一下. 问题描述:如下图,有N个sheet,每个sheet记录了一个公 ...

  6. shell 脚本请求接口报错

    2023-01-18 22:07:07.984 WARN 11700 --- [io-9044-exec-10] .w.s.m.s.DefaultHandlerExceptionResolver : ...

  7. clear

    BFC虽然可以达到外部背景由内部内容撑开的效果,但是存在副作用 所以由clear将affter受浮动效果解除,来解决以上问题

  8. 小白之Linux基础命令

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

  9. ref(代替id)

    App.vue <template> <div> <Student ref="str"/> <h3 v-text="age&qu ...

  10. C++ 17 遍历文件夹图片文件进行循环操作

    #include <filesystem>using namespace std;namespace fs = std::filesystem; string path = filepat ...