You need to sign in to do that
Don't have an account?
Jan Vandevelde
Question about redirect to multiple visualforce pages
Hi guru's,
I need a little help with the following. I've got several VF pages depending on language and division. The following apex class is a controller for a VF redirection page which will be called from the standard edit button on opportunity products.
So it starts from the edit link next to an opptylineitem on the opportunity and looks at some userfields as criteria which are already called from another class. After some if statements redirecting it to one of four possible custom pages I want all other users, not meeting the criteria to land on the standard edit functionality for which the URL should be: https://cs17.salesforce.com/OPPORTUNITYLINEITEMID/e?retURL=%2OPPORTUNITYID
Everything works except for the last redirect. I can't seem to be able to put the opportunityLineItemId in the URL. Also I got this far already being someone who has no coding experience whatsoever. So please be gentle. I know I has to be a stupid mistake, but I'm lost in translation here ;-)
Can someone help me?
public with sharing class opportunityProductRedirectExtension {
Id oppId;
private String userLanguage = UserUtil.CurrentUser.Language__c;
private String userDivision = UserUtil.CurrentUser.Division;
private String userLandcode = UserUtil.CurrentUser.Landcode__c;
// we are extending the OpportunityLineItem controller, so we query to get the parent OpportunityId
public opportunityProductRedirectExtension(ApexPages.StandardController controller) {
oppId = [select Id, OpportunityId from opportunityLineItem where Id = :controller.getRecord().Id limit 1].opportunityId;
}
// then we redirect to our desired page with the Opportunity Id in the URL
public pageReference redirect(){
if(userLanguage == 'fr' && userDivision == 'France'){
return new PageReference('/apex/opportunityProductEntryFR?id=' + oppId);
} else if(userLanguage == 'fr' && userDivision <> 'France'){
return new PageReference('/apex/opportunityProductEntryBE_FR?id=' + oppId);
} else if(userLanguage == 'nl_NL' && userLandcode == 'BE'){
return new PageReference('/apex/opportunityProductEntryBE_NL?id=' + oppId);
} else if(userLanguage == 'nl_NL' && userLandcode == 'NL' && (userDivision == 'Regio Zuid' || userDivision == 'Regio Noord' || userDivision == 'Landelijk Nederland')){
return new PageReference('/apex/opportunityProductEntry?id=' + oppId);
} else{
return new PageReference('/' + Id + '/e?retURL=%2' + oppId);
}
}
}
I need a little help with the following. I've got several VF pages depending on language and division. The following apex class is a controller for a VF redirection page which will be called from the standard edit button on opportunity products.
So it starts from the edit link next to an opptylineitem on the opportunity and looks at some userfields as criteria which are already called from another class. After some if statements redirecting it to one of four possible custom pages I want all other users, not meeting the criteria to land on the standard edit functionality for which the URL should be: https://cs17.salesforce.com/OPPORTUNITYLINEITEMID/e?retURL=%2OPPORTUNITYID
Everything works except for the last redirect. I can't seem to be able to put the opportunityLineItemId in the URL. Also I got this far already being someone who has no coding experience whatsoever. So please be gentle. I know I has to be a stupid mistake, but I'm lost in translation here ;-)
Can someone help me?
public with sharing class opportunityProductRedirectExtension {
Id oppId;
private String userLanguage = UserUtil.CurrentUser.Language__c;
private String userDivision = UserUtil.CurrentUser.Division;
private String userLandcode = UserUtil.CurrentUser.Landcode__c;
// we are extending the OpportunityLineItem controller, so we query to get the parent OpportunityId
public opportunityProductRedirectExtension(ApexPages.StandardController controller) {
oppId = [select Id, OpportunityId from opportunityLineItem where Id = :controller.getRecord().Id limit 1].opportunityId;
}
// then we redirect to our desired page with the Opportunity Id in the URL
public pageReference redirect(){
if(userLanguage == 'fr' && userDivision == 'France'){
return new PageReference('/apex/opportunityProductEntryFR?id=' + oppId);
} else if(userLanguage == 'fr' && userDivision <> 'France'){
return new PageReference('/apex/opportunityProductEntryBE_FR?id=' + oppId);
} else if(userLanguage == 'nl_NL' && userLandcode == 'BE'){
return new PageReference('/apex/opportunityProductEntryBE_NL?id=' + oppId);
} else if(userLanguage == 'nl_NL' && userLandcode == 'NL' && (userDivision == 'Regio Zuid' || userDivision == 'Regio Noord' || userDivision == 'Landelijk Nederland')){
return new PageReference('/apex/opportunityProductEntry?id=' + oppId);
} else{
return new PageReference('/' + Id + '/e?retURL=%2' + oppId);
}
}
}
} else{
system.debug('/' + Id + '/e?retURL=%2' + oppId');
return new PageReference('/' + Id + '/e?retURL=%2' + oppId);
}