我有一个Lead和一个名为Social Account的自定义对象(API Name = Social_Account__c).
我建立了如下关系:Lead是社交账户的父母.所以领导有很多社交账户.
在社交帐户中,我创建了一个名为Lead(数据类型:查找)的自定义字段来建立关系.
这是一个查找细节:
API名称:Lead__c
与铅有关
子关系名称:Social_Accounts
相关清单标签:社会账户
如果有一个具有相同电子邮件地址的潜在客户,我想向现有潜在客户添加新的社交帐户.
Social_Account__c social_account = new Social_Account__c();
/*add whatever fields on social_account*/
List<Lead> leads =[select Id from Lead where Email =:emailAddress ];
if(leads.size()>0)
{
Lead existing_lead = new Lead(Id = leads[0].id);
//ideally i would like to do something like this
social_account.Lead__c.id = existing_lead.id; //this is where I get an error from
insert social_account;
update existing_lead;
}
Run Code Online (Sandbox Code Playgroud)
但我收到以下错误消息:
错误:编译错误:外键关系无效:Social_Account_ c.Lead _c
我究竟做错了什么?我将不胜感激任何建议.
谢谢
我有一个自定义门户与自定义站点集成,使用 Apex/Visualforce。我想在为站点/门户启用的 Visualforce 页面上提供自定义密码更改功能。
Site 静态类方法几乎没有文档记录,在结合 developerforce.com 并发现空之后,我想我会在这里尝试。这是方法(在示例 ChangePasswordController 类中找到)
Site.changePassword(newPassword, verifyNewPassword, oldpassword);
Run Code Online (Sandbox Code Playgroud)
这是踢球者。无论我为这些值输入什么数据,包括遵守所有密码策略,该方法都会简单地返回 null 并且什么都不做。有趣的是,在 Salesforce 提供的示例测试方法中,断言字面上证明了这种情况:
/**
* An apex page controller that exposes the change password functionality
*/
public with sharing class ChangePasswordController {
public String oldPassword {get; set;}
public String newPassword {get; set;}
public String verifyNewPassword {get; set;}
public PageReference changePassword() {
return Site.changePassword(newPassword, verifyNewPassword, oldpassword);
}
public ChangePasswordController() {}
public static testMethod void testChangePasswordController() {
// Instantiate a new controller with all parameters …Run Code Online (Sandbox Code Playgroud) 该公司最近发现需要在Visualforce/Apex中创建并排记录.我们通常需要将潜在客户合并到联系人中.以前这是在S-Controls处理的; 然而,最近的举措和希望在未来支持我们的代码,这促使我们将许多S-Controls转移到Visualforce页面和Apex代码中.
我们希望实现这样的目标:

我用apex:pageBlockTable标签做了一些尝试(运气不大); 但是,我不确定如何在需要单个SObject时获取两组数据.
我必须使用的所有先前代码都是使用JavaScript在S-Controls中完成的; 虽然这段代码现在可以正常工作 - 我们需要将它移植到VisualForce页面.显然我可以使用HTML表格等手动编写它,但我相信这会破坏使用Salesforce库存功能的目的.
我肯定对替代方法持开放态度 - 正如我所概述的那样,但需要几乎痛苦的编码才能使其可行(特别是在将来更新/删除/添加字段时).
我试图使用REST API从salesforce中的字段中获取所有选项列表值.有可能吗?如果它是如何做到的?
谢谢,
拉吉.
我使用 Visual Studio Code 并根据https://developer.salesforce.com/tools/vscode/en/user-guide/prettier (也https://www.sfdcnotes)安装了 Prettier 插件以及 Prettier-plugin-apex .com/2019/12/16/vs-code-extension-prettier-code-formatter/)。
它曾经用来格式化我的类,但最近一直失败,但我所看到的只是右下角的内容,没有解释我保存类文件时出现的问题(它在保存时格式化/在保存时部署)。
当我尝试手动格式化时,npx prettier --write出现此错误:
PS C:\Users\xx\Documents\VSC\SynDev> npx prettier --write force-
app/main/default/classes/emailReportController_Test.cls
force-app\main\default\classes\emailReportController_Test.cls
[error] force-app\main\default\classes\emailReportController_Test.cls: Error
[error] at parseTextWithSpawn (C:\Users\xx\Documents\VSC\SynDev\node_modules\prettier-plugin-apex\src\parser.js:36:11)
[error] at Object.parse (C:\Users\xx\Documents\VSC\SynDev\node_modules\prettier-plugin-apex\src\parser.js:489:21)
[error] at Object.parse$a [as parse] (C:\Users\xx\Documents\VSC\SynDev\node_modules\prettier\index.js:14892:19)
[error] at coreFormat (C:\Users\xx\Documents\VSC\SynDev\node_modules\prettier\index.js:16425:16)
[error] at formatWithCursor$1 (C:\Users\xx\Documents\VSC\SynDev\node_modules\prettier\index.js:16665:14)
[error] at Object.formatWithCursor (C:\Users\xx\Documents\VSC\SynDev\node_modules\prettier\index.js:60922:12)
[error] at format$1 (C:\Users\xx\Documents\VSC\SynDev\node_modules\prettier\bin-prettier.js:16107:14)
[error] at Object.formatFiles$1 [as formatFiles] (C:\Users\xx\Documents\VSC\SynDev\node_modules\prettier\bin-prettier.js:16218:16)
[error] at main (C:\Users\xx\Documents\VSC\SynDev\node_modules\prettier\bin-prettier.js:17989:10)
[error] at Object.run (C:\Users\xx\Documents\VSC\SynDev\node_modules\prettier\bin-prettier.js:17932:5)
Run Code Online (Sandbox Code Playgroud)
我该如何解决这个问题 - 出了什么问题(我不是 VSC 或 npm …
由于标准的页面布局不允许您调整绑定到一个文本字段的inputfield的宽度,我试图创建一个VisualForce页,但没有为顶点的宽度属性:inputfield组件.我想我将不得不使用样式或CSS或其他东西,但我不知道如何.
我需要做些什么才能调整文本输入字段的宽度?
请使用Web界面(而非Force.com IDE)提供说明.谢谢.
编辑
我最终使用了这样的嵌入式样式
<apex:inputfield value="{!Country__c.Full_Name__c}" style="width:400px"/>
Run Code Online (Sandbox Code Playgroud) <apex:outputField rendered="{!(WidgetType.contains('mywidget1'))}" />
Run Code Online (Sandbox Code Playgroud)
当我这样做时,我得到一个错误......
错误:未知函数WidgetType.contains.检查拼写
...即使WidgetType返回一个字符串!
它会让我这样做......
rendered ="{!(WidgetType =='mywidget1')}"
这是控制器中的属性......
public String getWidgetType() {
return Settings.getWidgetType();
}
Run Code Online (Sandbox Code Playgroud) 我有一个Visualforce页面,我想显示特定sObject表中记录数的计数.
在Visualforce页面中,我有一些相当简单的东西,比如:
<p>Client Account Count: {!ClientAccountCount}</p>
Run Code Online (Sandbox Code Playgroud)
然后在控制器中:
// Return the number of clients
public integer getClientAccountCount() {
return [Select count() from Account where SomeCustomField__c = 'Client' limit 50000];
}
Run Code Online (Sandbox Code Playgroud)
我认为在SOQL中使用limit子句我会很好,因为它只会返回最多50,000个.但是,实际上我仍然在生产组织中得到这个例外:
09:29:12:179 SOQL_EXECUTE_BEGIN [108] |聚合:0 |从Account中选择count(),其中SomeCustomField__c ='Client'限制50000
09:29:12:331 EXCEPTION_THROWN [108] | System.LimitException:查询行太多:50001
有没有一种安全的方法来执行此查询,不会导致我无法捕获的异常?
奇怪的是,如果我在生产中尝试以下作为匿名顶点它可以正常工作并返回50,000.
integer count = [select count() from Account where SomeCustomField__c = 'Client' limit 50000];
Run Code Online (Sandbox Code Playgroud)
也许问题是导致问题的所有操作的累积查询行数,我需要在运行查询之前检查代码中的限制?
Force.com讨论板上有一篇类似的帖子 - COUNT(*)函数上的查询行太多了.我无法将VF页面设置为只读以增加查询行限制.
我不是100%肯定如何描述我想要做的事情,所以我提前道歉.
我在salesforce中有一个对象的自定义输入页面,我很好奇在单击保存按钮时是否可以调用外部网站.
粗略的例子:
我再次道歉.我知道我并没有很好地描述这一点.感谢您的任何和所有输入!
我收到错误"错误错误:AddIMRConroller编译错误:字段表达式的初始术语必须是具体的SObject:LIST在第21行第23行"来自下面的代码行.
string [] str1 = imrTable.split('\ r \n'); System.debug(str1.length);
apex-code ×10
salesforce ×8
visualforce ×6
force.com ×1
javascript ×1
jquery ×1
npm ×1
npx ×1
prettier ×1
soql ×1