You need to sign in to do that
Don't have an account?
Ludivine
How to replace a hard-coded url by a function in an Apex Class?
Hi,
I have received a mesage from salesforce which say that they are going to move our org to a new one. from EU0 to EU3.
I have searched in all my org and I have found an Apex Class where this url is hard-coded.
I need to know how to re-write this with a function because it is not "nice" to have this and I don't want to replace eu0 by EU3...
str='https://c.cs4.visual.force.com/apex/eventview?id='+eid;
//prod : str='https://c.eu0.visual.force.com/apex/eventview?
Could you help me here?thank you very much in advance.
public PageReference redirect1() { String eventId=ApexPages.currentPage().getParameters().get('newid'); String eid=ApexPages.currentPage().getParameters().get('id'); string str; System.debug('#######'+eventId+'@@@@@@@'+eid); // if((eid.length()<6) && (eventId.length()>10)) if(eid.length()>10) { str='https://c.cs4.visual.force.com/apex/eventview?id='+eid; //prod : str='https://c.eu0.visual.force.com/apex/eventview?id='+eventId; system.debug(str); } PageReference r= new PageReference(str); r.setRedirect(true); System.debug('##str=https://c.cs4.visual.force.com/apex/eventview?id=+eventId =##'+str); // return null; return r; }
You can try this:
Pagerefence page = new Pagereference('/apex/MyFirstPage?id='+eid);
page.setRedirect(true);
return page;
As we are not hardcoding any URL here it will work without worrying about change of salesforce instance numbers.
Thanks,
Devendra
All Answers
You can try this:
Pagerefence page = new Pagereference('/apex/MyFirstPage?id='+eid);
page.setRedirect(true);
return page;
As we are not hardcoding any URL here it will work without worrying about change of salesforce instance numbers.
Thanks,
Devendra
Thank you!!! I have amended the Apex class and it is working fine, could you check my code , do you see anything that should be simplified?
I dont know what logic your are applying here.
But, about Pagereference statements, now its perfect..Thumps Up!!
Thanks,
Devendra