Salesforce 尝试将重定向页面上的输出链接从另一个VF页面添加到新创建的Opportunity
SF管理员尝试进入开发阶段。尝试使用Force.com网站、Apex和VF的组合创建一些web to opportunity功能。它起作用了,创造了机会。当Opp保存在VF页面上时,它会重定向到另一个VF页面,表示祝贺!新创建的Opp等。我想在这个重定向页面上添加一个链接或按钮,让用户可以选择导航到新创建的Opp,如果他们愿意,但是我没有太多的运气 控制器:Salesforce 尝试将重定向页面上的输出链接从另一个VF页面添加到新创建的Opportunity,salesforce,apex,visualforce,Salesforce,Apex,Visualforce,SF管理员尝试进入开发阶段。尝试使用Force.com网站、Apex和VF的组合创建一些web to opportunity功能。它起作用了,创造了机会。当Opp保存在VF页面上时,它会重定向到另一个VF页面,表示祝贺!新创建的Opp等。我想在这个重定向页面上添加一个链接或按钮,让用户可以选择导航到新创建的Opp,如果他们愿意,但是我没有太多的运气 控制器: public class OpportunityInformationPage{ public opportunity oppSt
public class OpportunityInformationPage{
public opportunity oppString{get;set;}
public OpportunityInformationPage(){
oppString = new opportunity();
}
public PageReference Saveto(){
opportunity opp = new opportunity();
opp.name = oppString.name;
opp.closedate = oppString.closedate;
opp.stagename = oppString.stagename;
opp.amount = oppString.amount;
opp.impact_level__c = oppString.impact_level__c;
insert opp;
PageReference reRend = new PageReference('/apex/Opportunity_Created');
reRend.setRedirect(true);
return reRend;
}
}
public class OpportunityInformationPage{
public opportunity oppString{get;set;}
public Boolean bOppCreated{get;set;}
public String opp_sfid{get;set;}
public OpportunityInformationPage(){
oppString = new opportunity();
bOppCreated = false;
opp_sfid = null;
}
public PageReference Saveto(){
opportunity opp = new opportunity();
opp.name = oppString.name;
opp.closedate = oppString.closedate;
opp.stagename = oppString.stagename;
opp.amount = oppString.amount;
opp.impact_level__c = oppString.impact_level__c;
insert opp;
bOppCreated = true;
opp_sfid = opp.id;
return null;
}
}
用于输入Opp详细信息的VF页面:
<apex:page controller="OpportunityInformationPage" showHeader="false" sidebar="false">
<apex:sectionHeader title="New Opportunity"/>
<apex:form >
<apex:pageBlock title="Opportunity Edit" mode="edit">
<apex:pageBlockButtons >
<apex:commandButton value="Save" action="{!Saveto}"/>
</apex:pageBlockButtons>
<apex:pageBlockSection title="Opportunity Information">
<apex:inputField value="{!oppString.name}"/>
<apex:inputField value="{!oppString.closeDate}"/>
<apex:inputField value="{!oppString.stageName}"/>
<apex:inputField value="{!oppString.amount}"/>
<apex:inputField value="{!oppString.Impact_Level__c}"/>
</apex:pageBlockSection>
</apex:pageBlock>
</apex:form>
</apex:page>
祝贺页面,我希望链接/按钮发送到SF:
<apex:page controller="OpportunityInformationPage" showheader="false" sidebar="false">
<apex:PageBlock >
<apex:pageBlockSection >
<apex:outputText value="Congratulations! New Opportunity Succesfully Created" /> <br/>
</apex:pageBlockSection>
</apex:PageBlock>
</apex:page>
如有任何建议,欢迎提供帮助。我不知道您创建opportunity后为什么要重定向到新页面。为什么不在当前页面上显示成功消息并添加指向新页面的链接
public class OpportunityInformationPage{
public opportunity oppString{get;set;}
public Boolean bOppCreated{get;set;}
public OpportunityInformationPage(){
oppString = new opportunity();
bOppCreated = false;
}
public PageReference Saveto(){
opportunity opp = new opportunity();
opp.name = oppString.name;
opp.closedate = oppString.closedate;
opp.stagename = oppString.stagename;
opp.amount = oppString.amount;
opp.impact_level__c = oppString.impact_level__c;
insert opp;
bOppCreated = true;
return null;
}
}
<apex:page controller="OpportunityInformationPage" showHeader="false" sidebar="false">
<apex:sectionHeader title="New Opportunity"/>
<apex:form >
<apex:pageBlock title="Opportunity Edit" mode="edit">
<apex:pageBlockButtons >
<apex:commandButton value="Save" action="{!Saveto}" rerender="mainBlock" />
</apex:pageBlockButtons>
<apex:outputpanel id="mainBlock">
<apex:pageBlockSection title="Opportunity Information" rendered="{!NOT(bOppCreated)>
<apex:inputField value="{!oppString.name}"/>
<apex:inputField value="{!oppString.closeDate}"/>
<apex:inputField value="{!oppString.stageName}"/>
<apex:inputField value="{!oppString.amount}"/>
<apex:inputField value="{!oppString.Impact_Level__c}"/>
</apex:pageBlockSection>
<apex:pageBlockSection rendered="{!bOppCreated}">
<apex:outputText value="Congratulations! New Opportunity Succesfully Created" /> <br/>
<apex:outputlink value="/{!oppString.id}">{!oppString.Name}</apex:outputlink>
</apex:pageBlockSection>
</apex:outputpanel>
</apex:pageBlock>
</apex:form>
</apex:page>
公共类机会信息页面{
公共字符串{get;set;}
公共布尔bOppCreated{get;set;}
公共机会信息页(){
oppString=新机会();
bOppCreated=false;
}
公共页面引用Saveto(){
opportunity opp=新opportunity();
opp.name=oppString.name;
opp.closedate=oppString.closedate;
opp.stagename=oppString.stagename;
opp.amount=oppString.amount;
opp.impact\u level\uuu c=oppString.impact\u level\uu c;
插入opp;
bOppCreated=true;
返回null;
}
}
首先,将控制器中的reRend.setRedirect(true)修改为reRend.setRedirect(false)
第二件事是,当你想在新家具制作后显示信息时,
为什么我们需要另一个控制器?。。
在Saveto()方法中插入新机会之后
添加
addmessage(新的ApexPages.message(ApexPages.severity.INFO,'newoppournity is created')
在VisualForce页面中,只需提及apex:pagemessages即可调用此消息/
现在在apex:outputlink中提到了新创建的TD机会,感谢Psymn为我指明了正确的方向。由于记录ID为空,输出链接将我放在“主页”选项卡上(我想这可能是因为我没有使用标准控制器-Dev n00b抱歉)。创建了一个字符串变量以获取ID的值,并在执行该操作的输出链接中引用了该变量
控制器:
public class OpportunityInformationPage{
public opportunity oppString{get;set;}
public OpportunityInformationPage(){
oppString = new opportunity();
}
public PageReference Saveto(){
opportunity opp = new opportunity();
opp.name = oppString.name;
opp.closedate = oppString.closedate;
opp.stagename = oppString.stagename;
opp.amount = oppString.amount;
opp.impact_level__c = oppString.impact_level__c;
insert opp;
PageReference reRend = new PageReference('/apex/Opportunity_Created');
reRend.setRedirect(true);
return reRend;
}
}
public class OpportunityInformationPage{
public opportunity oppString{get;set;}
public Boolean bOppCreated{get;set;}
public String opp_sfid{get;set;}
public OpportunityInformationPage(){
oppString = new opportunity();
bOppCreated = false;
opp_sfid = null;
}
public PageReference Saveto(){
opportunity opp = new opportunity();
opp.name = oppString.name;
opp.closedate = oppString.closedate;
opp.stagename = oppString.stagename;
opp.amount = oppString.amount;
opp.impact_level__c = oppString.impact_level__c;
insert opp;
bOppCreated = true;
opp_sfid = opp.id;
return null;
}
}
VF页面:
<apex:page controller="OpportunityInformationPage" showHeader="false" sidebar="false">
<apex:sectionHeader title="New Opportunity"/>
<apex:form >
<apex:pageBlock title="Opportunity Edit" mode="edit">
<apex:pageBlockButtons >
<apex:commandButton value="Save" action="{!Saveto}" rerender="mainBlock"/>
</apex:pageBlockButtons>
<apex:outputPanel id="mainBlock">
<apex:pageBlockSection title="Opportunity Information" rendered="{!NOT(bOppCreated)}">
<apex:inputField value="{!oppString.name}"/>
<apex:inputField value="{!oppString.closeDate}"/>
<apex:inputField value="{!oppString.stageName}"/>
<apex:inputField value="{!oppString.amount}"/>
<apex:inputField value="{!oppString.Impact_Level__c}"/>
</apex:pageBlockSection>
<apex:pageBlockSection rendered="{!bOppCreated}">
<apex:outputText value="Congratulations! New Opportunity Succesfully Created" /> <br/>
<apex:outputlink value="/{!opp_sfid}">{!oppString.Name}</apex:outputlink>
</apex:pageBlockSection>
</apex:outputpanel>
</apex:pageBlock>
</apex:form>
</apex:page>
{!oppString.Name}
感谢feeback Psymn…不幸的是,输出链接将我放入主页选项卡,而不是机会。看起来我需要一种方法来将该页创建的Opportunity的ID存储在控制器中,并将其传递回VF,以便在输出链接中使用。您知道如何实现这一点吗?摆弄控制器/VF页面,最终使其工作。我将发布修改后的代码。