salesforce - 尝试将重定向页面上的输出链接添加到来自另一个 VF 页面的新创建的机会
问题描述
SF Admin 试图进入 Dev。尝试使用 Force.com 站点、Apex 和 VF 的组合创建一些网络机会功能。它有效并且创造了机会。当 Opp 保存在 VF 页面上时,它会重定向到另一个 VF 页面,上面写着 Congrats!创建了新的 Opp 等。我想在此重定向页面上添加一个链接或按钮,以便用户可以选择导航到新创建的 Opp(如果他们愿意)但是我运气不佳。
控制器:
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;
}
}
VF 页面输入 Opp 详细信息:
<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>
任何建议,帮助表示赞赏。
解决方案
我不确定您为什么在创建机会后重定向到新页面。为什么不在当前页面上显示成功消息并添加指向新页面的链接
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>
推荐阅读
- html - 将表格中的最后一个标题设置为自动调整行中按钮的大小
- python - 复数中的 Mandelbrot 集绘图和 ZeroDivisionError
- android - ReactNative & Expo - 错误:“值”是只读的
- angular - Ngx-Chart 不显示数据
- excel - 如何比较多个命名列范围中相应单元格的值并更改另一个相应单元格中的内部颜色
- python - PyLint W0231 super-init-not-call with __init__ of祖父母
- php - 在 xampp 的 phpmyadmin 的第 2302 行的 Util.php 中显示内存不足
- angular - PrimeNG 分页器设置页面
- django - 如何响应 django ckeditor
- android - 在 NavigationView 上 colorSurface 和背景发生冲突