[英]Click on new button redirect to vf page based on the profile
我有一个要求,如果我单击自定义对象的“新建”按钮,则如果这是支持配置文件,则应将其重定向到VF页面。 否则它应该显示标准页面。 有人可以帮我弄这个吗。 以下是我尝试过的代码。
<apex:page standardController="customobject__c" extensions="customvfpagecontroller1" action="{!redirect}">
public PageReference redirect() {
PageReference newPage;
Id tProfile = [select Id from Profile where Name = 'TSupport' limit 1][0].Id;
Id profileId=userinfo.getProfileId();
if(profileId == tProfile)
{
newPage = Page.vfpage1;
return newPage.setRedirect(true);
} else {
//it should redirect to standard new page of the custom object
}
在“自定义对象”页面的最顶部,单击“按钮,链接和操作”>“新建按钮或链接”。
将其标记为New,并将其命名为New_Custom或其他名称。
然后,您的逻辑可以遵循
IF({!$Profile.Name}=='TSupport','/apex/vfpage1',URLFOR($Action.CustomObject__c.New, null, save=1))
不幸的是,由于那里不支持$ Page,因此必须静态设置/ apex / vfpage1。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.