在 Salesforce 中的记录类型之间转换

发布于 2024-11-29 16:14:54 字数 830 浏览 0 评论 0原文

Salesforce 允许您使用记录类型来扩展对象定义。是否有一种快速简便的方法允许用户将对象组从一种记录类型转换为另一种记录类型?就我而言,我将跟踪学生从申请人到校友的本科生生命周期的进展。对我来说,将学生生命周期的不同阶段作为记录类型进行跟踪是有意义的,以便我可以为每个阶段创建自定义界面/查看权限/业务逻辑。我希望能够创建一个自定义按钮或链接来按照 Salesforce 的示例执行此操作: Salesforce:按钮和链接入门。 然而,我没能使用 Ajax 工具包查询 RecordType 对象来找出我需要将对象更新为哪个 RecordTypeId。 (我对 JavaScript 相当陌生,所以这可能只是我的经验不足造成的。如果有人问的话,我很乐意发布我迄今为止尝试过的代码示例。)

在 IdeaExchange 上,有人提到你可以将 RecordType 字段包含在对象的自定义布局页面中 (IdeaExchange:提供更改记录类型的方法),但这看起来并不像管理数百名学生的合理解决方案。

使用工作流或触发器似乎也不是一种合理的解决方案,因为它们显然需要您更新记录或创建新记录。学生应该能够随时进行过渡,不受更新或新增内容的影响。

当你提到你的问题可能涉及的其他事情时,我很喜欢它,但我认为这些领域在这里是不言自明的;每当您想要以编程方式在不同记录类型之间进行转换时,此问题都是相关的。

Salesforce allows you to extend Object definitions by using Record Types. Is there a quick and easy way to allow users to transition groups of Objects from one Record Type to another? In my case, I will be keeping track of students as they progress through the undergraduate student life cycle from applicant to alumnus. It makes sense to me to keep track of the different phases of the student life cycle as Record Types so that I can create custom interfaces/viewing permissions/business logic for each phase. I was hoping to be able to create a custom button or link to do this as per this example from Salesforce:
Salesforce: Getting Started With Buttons and Links.
However I have had no luck querying the RecordType object using the Ajax toolkit to find out which RecordTypeId I will need to update the Object to. (I am rather new to JavaScript so it may simply be my inexperience that's getting in the way. I would be happy to post code samples of what I've tried so far if anyone asks.)

On the IdeaExchange someone mentioned that you can just include the RecordType field in the object's custom layout page (IdeaExchange: Provide a Means of Changing Record Types), but this does not seem like a reasonable solution for managing hundreds of students.

Using a workflow or a trigger does not seem like a reasonable solution either because those apparently require you to update a record or create a new one. Students should be able to transition at any time, independently of updates or new additions.

SO likes it when you mention other things that your issue could pertain to, but I think those areas are pretty self-explanatory here; this issue is relevant any time you might like to programatically transition between different record types.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

落在眉间の轻吻 2024-12-06 16:14:54

您想要的可能不是 RecordType 对象本身,而是您用来跟踪查找该 RecordType 对象的学生的对象上的 RecordTypeId 字段。例如,要查找给定学生的记录类型,SOQL 将如下所示:

SELECT RecordTypeId FROM Student__c WHERE Id = {some id}

然后,如果您想更新记录,您可以更改 RecordTypeId 的值,如下所示:

var student = new sforce.SObject("Student__c");
student.Id = '{some id}';
student.RecordTypeId = '{new record type id}';
result = sforce.connection.update([student]);

查找给定对象类型的合格 RecordTypeId ,您可以查询 RecordType 对象并在 SObjectType 列上进行筛选,或者仅调用 describeSObject(Student__c) 并检查中的 RecordTypeInfos 节点结果。

What you want is probably not the RecordType object itself, but rather the RecordTypeId field on your object you are using to track students which looks up to that RecordType object. For example, to find the record type of a given student, the SOQL would look like:

SELECT RecordTypeId FROM Student__c WHERE Id = {some id}

and then if you wanted to update the record, you could change the value of the RecordTypeId like this:

var student = new sforce.SObject("Student__c");
student.Id = '{some id}';
student.RecordTypeId = '{new record type id}';
result = sforce.connection.update([student]);

To find the eligible RecordTypeIds for a given object type, you can either query the RecordType object and filter on the SObjectType column, or just call describeSObject(Student__c) and inspect the RecordTypeInfos node in the result.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文