[英]Click on new button redirect to vf page based on the profile
I have a requirement in which if i click on new button of a custom object, it should get redirected to a VF page if this is a support profile. 我有一个要求,如果我单击自定义对象的“新建”按钮,则如果这是支持配置文件,则应将其重定向到VF页面。 else it should show the standard page.
否则它应该显示标准页面。 can someone help me with this.
有人可以帮我弄这个吗。 Below is the code i have tried.
以下是我尝试过的代码。
<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
}
On the Custom Object page, at the very top click "Buttons, Links, and Actions" > New Button or Link. 在“自定义对象”页面的最顶部,单击“按钮,链接和操作”>“新建按钮或链接”。
Label it New, and Name it New_Custom or something. 将其标记为New,并将其命名为New_Custom或其他名称。
Then your logic can be along the lines of 然后,您的逻辑可以遵循
IF({!$Profile.Name}=='TSupport','/apex/vfpage1',URLFOR($Action.CustomObject__c.New, null, save=1))
You'll unfortunately have to statically set the /apex/vfpage1 since $Page is not supported there. 不幸的是,由于那里不支持$ Page,因此必须静态设置/ apex / vfpage1。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.