You need to sign in to do that
Don't have an account?
BobP
Test class to check user profile and page reference
I am working on a apex class for the opportunity object to display a visualforce page if the current user has a specific profile i.e. System Administrator. I'm not sure how to write a test class to check user profiles and page references. Any help on this would be greatly appreciated.
Apex Class:
Apex Class:
public class overrideOpp { String recordId; public overrideOpp(ApexPages.StandardController controller) {recordId = controller.getId();} public PageReference redirect() { Profile p = [select name from Profile where id = :UserInfo.getProfileId()]; if ('System Administrator'.equals(p.name) || 'Inside Standard User'.equals(p.name)) { PageReference customPage = Page.OppTabDetailinsidesales2; customPage.setRedirect(true); customPage.getParameters().put('id', recordId); return customPage; } else { return null; //otherwise stay on the same page } } }
All Answers