我在Visualforce页面上得到了奇怪的结果(是的,Salesforce.com很icky,我知道).我的问题是我尝试使用inputField绑定自定义sObject上的数据,但在我的自定义控制器中,它无法识别用户输入数据.
以下是该页面的代码段:
<apex:pageBlockSection title="Enter New Fee" rendered="{!isRenderedFees}" >
<apex:inputField value="{!workingFee.Fee_Type__c}" required="True"/>
<apex:inputField value="{!workingFee.Fee__c}" required="True"/>
<apex:pageBlockSectionItem >
<apex:CommandButton value="Save Fee" action="{!saveFee}" immediate="true" />
<apex:CommandButton value="Cancel" action="{!cancelFee}" immediate="true" />
</apex:pageBlockSectionItem>
</apex:pageBlockSection>
Run Code Online (Sandbox Code Playgroud)
这是来自控制器的代码:
public Fee__c workingFee {get; set;}
....
public PageReference saveFee(){
this.workingFee.Trade_Group__c = tradeGroup.id;
try{
System.debug('~~~~#~~#~~workingFee: '+workingFee.Fee_Type__c +'='+workingFee.Fee__c);
upsert workingFee;
}catch (System.Dmlexception e){
ApexPages.addMessages(e);
return null;
}
System.debug('~~~~#~~#~~workingFee: '+workingFee.Fee_Type__c +'='+workingFee.Fee__c);
//savedFees.add(workingFee.clone());
//re-render the page
this.isRenderedFees = False;
return null;
}
Run Code Online (Sandbox Code Playgroud)
我已确保workingFee属性不为null.每当我输入值后点击"保存费"按钮,它就会重新加载页面并给我一条消息"错误:缺少必填字段:[Fee__c]"(注意,这里的费用是一个货币字段 - 不是它期望这是一个sObject,是吗?)
saveFee()方法中的debug语句显示workingFee的重要字段为null,当我希望它们被赋予用户输入的值时.
是否可以在salesforce.com中创建自定义登录页面?如果是这样,任何人都可以提供帮助来创建页面和验证部分?
我有一个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
我究竟做错了什么?我将不胜感激任何建议.
谢谢
这是我在Salesforce开发板上询问的一个问题的扩展:
我有一个VisualForce页面,需要经常更改从控制器加载新信息并将该信息嵌入到Javascript数组中以供进一步使用.
Curent解决方案:我已经成功使用了VisualForce'浏览器技术',如此处所述(在Wiki中):http://wiki.developerforce.com/index.php/Using_Browser_Technologies_in_Visualforce_-_Part_1
我用推荐的标签包围Javascript array.push:
<apex:repeat value="{!Object}" var="objects">
d.push( {
element1: "{!objects.id}"
})
</apex:repeat>
Run Code Online (Sandbox Code Playgroud)
问题:当整个页面刷新填充时,阵列被正确填充,当我使用"下拉"修改对象上的过滤器(在控制器中)时,DOM被更新(我可以看到新信息被放置在页面上) )
然而,最终,Javascript数组不会改变它的值,除非我在整个页面上调用刷新,这会使部分刷新失败并且对用户来说是一种冲击.
这个"必要的帖子"问题以前不是问题,甚至在我更新DOM后直接调用包含此数组的Javascript函数时,Javascript数组也不会改变(所以我假设它已经加载了一次基于当页面最初回发并且无法更改时DOM上的内容.
思考?
我在apex中有一个抽象类,有几个属性我想在子类中重写.根据文档,属性支持覆盖和虚拟访问修饰符.但是,当我尝试在父类或子类中使用它们中的任何一个时,我得到一个错误,指出变量不能标记为虚拟/覆盖.以下是导致此错误的代码的传真:
public abstract class Row{
public virtual double value{
get{return value==null ? 0 : value;}
set;
}
}
public class SummaryRow extends Row{
private list<Row> childRows;
public override double value{
get{
totalValue = 0;
for(Row childRow:childRows){
totalvalue += childRow.value;
}
return totalValue;
}
}
}
Run Code Online (Sandbox Code Playgroud)
是不支持此功能,还是我缺少某些功能?
提前致谢.
当我调用函数add()时出现以下错误
You have uncommitted work pending. Please commit or rollback before calling out
我调用getItems()填充下拉列表,然后add调用函数从下拉列表中插入所选项
public PageReference add() {
insert technology;
return null;
}
public List<SelectOption> getItems() {
List<SelectOption> options = new List<SelectOption>();
List<Technology__c> AddedT=[SELECT Name FROM Technology__c];
HttpRequest req = new HttpRequest();
req.setMethod('GET');
req.setEndpoint('http://submit.toolsberry.com/sfdc/technologies');
Http http = new Http();
HTTPResponse res = http.send(req);
String response=res.getBody();
XmlStreamReader reader = new XmlStreamReader(response);
List<String> AllTech = new List<String>();
while(reader.hasNext()) {
if (reader.getEventType() == XmlTag.START_ELEMENT) {
if ('string' == reader.getLocalName()) …Run Code Online (Sandbox Code Playgroud) 我目前正在使用Apex工作簿来刷新我对SalesForce的了解.
教程#15,第1课:提供以下代码:
global class CleanUpRecords implements Database.Batchable<Object>
{
global final String query;
global CleanUpRecords (String q) {query = q;}
global Database.Querylocator start (Database.BatchableContext BC)
{
return Database.getQueryLocator(query);
}
global void execute (Database.BatchableContext BC, List<sObject> scope)
{
delete scope;
Database.emptyRecycleBin(scope);
}
global void finish(Database.BatchableContext BC)
{
AsyncApexJob a = [
SELECT Id, Status, NumberOfErrors, JobItemsProcessed, TotalJobItems, CreatedBy.Email
FROM AsyncApexJob
WHERE Id = :BC.getJobId()
];
// Send an email to the Apex job's submitter
// notifying of job completion.
Messaging.SingleEmailMessage …Run Code Online (Sandbox Code Playgroud) 该公司最近发现需要在Visualforce/Apex中创建并排记录.我们通常需要将潜在客户合并到联系人中.以前这是在S-Controls处理的; 然而,最近的举措和希望在未来支持我们的代码,这促使我们将许多S-Controls转移到Visualforce页面和Apex代码中.
我们希望实现这样的目标:

我用apex:pageBlockTable标签做了一些尝试(运气不大); 但是,我不确定如何在需要单个SObject时获取两组数据.
我必须使用的所有先前代码都是使用JavaScript在S-Controls中完成的; 虽然这段代码现在可以正常工作 - 我们需要将它移植到VisualForce页面.显然我可以使用HTML表格等手动编写它,但我相信这会破坏使用Salesforce库存功能的目的.
我肯定对替代方法持开放态度 - 正如我所概述的那样,但需要几乎痛苦的编码才能使其可行(特别是在将来更新/删除/添加字段时).
我想在2行中显示apex:列标题.我的标题为"分布式总计"的列我希望以2行显示
<apex:column headerValue="Distributed Total$">
<apex:outputText value="${0, number, ###,##0.00}">
<apex:param value="{!item.Dtotal}"/>
</apex:outputText>
</apex:column>
Run Code Online (Sandbox Code Playgroud)
知道如何实现这一目标
谢谢
普拉迪普
我正在尝试与我的Apex-Webservice建立连接,但每次都失败.我的Webserce非常简单:
global class AtlassianService
{
webService static String hello(String Name)
{
return 'Hello '+Name+' ! :D';
}
}
Run Code Online (Sandbox Code Playgroud)
生成客户端,我只是顺便说一句,这是描述在这里:
java –classpath pathToJAR/wsc-22.jar com.sforce.ws.tools.wsdlc pathToWsdl/WsdlFilename? pathToOutputJar/OutputJarFilename
Run Code Online (Sandbox Code Playgroud)
访问Web服务:
SoapConnection soap = Connector.newConnection("mail@XXXXXX.com", "XXXX");
System.out.println(soap.hello("WORLD")); // Invalid Session ( => SessionID is null)
Run Code Online (Sandbox Code Playgroud)
如果我使用PartnerConnection获取有效的SessionID,一切正常:
ConnectorConfig config = new ConnectorConfig();
config.setUsername(username);
config.setPassword(password);
config.setAuthEndpoint("https://login.salesforce.com/services/Soap/u/24.0");
new PartnerConnection(config);
SoapConnection soap = Connector.newConnection(null, null);
soap.setSessionHeader(config.getSessionId());
System.out.println(soap.hello("WORLD"));
Run Code Online (Sandbox Code Playgroud)
任何人都知道为什么第一个例子失败了?
问候塞巴斯蒂安
apex-code ×10
salesforce ×10
visualforce ×5
javascript ×2
class ×1
java ×1
properties ×1
save ×1
soap ×1
web-services ×1