You need to sign in to do that
Don't have an account?
udayar_jayam
Get Current Page URL in Apex Class
Hi All,
How to write apex class for to get dynamic url in any record and objects.
function readOnly(count){ }
You need to sign in to do that
Don't have an account?
Hi All,
How to write apex class for to get dynamic url in any record and objects.
Hi,
To get the URL of the current page u can use ApexPages.currentPage() methods.
String hostVal = ApexPages.currentPage().getHeaders().get('Host');
String urlVal = Apexpages.currentPage().getUrl();
String URLL = 'https://' + hostVal+ urlVal; // Add the hostVal and urlVal and it will give u the URL value
Please refer the following link:
http://www.salesforce.com/us/developer/docs/apexcode/Content/apex_pages_pagereference.htm
Please let me know if u have any problem on same,and if this post help you please give KUDOS by click on star at left.
In order to get the url in apex class u can use Apexpages.currentPage().getUrl();
thanks for reply Puja and dev how to get the URL of My oppaortunity List view
Hi,
you need to findout the keyPrefix of opportunity object
public string findObjectAPIName( String ObjectName ){
String keyPrefix = '';
schema.DescribeSObjectResult d = Schema.getGlobalDescribe().get(ObjectName).getDescribe();
keyPrefix = d.getKeyPrefix();
return keyPrefix ;
}
and use like that :
String hostVal = ApexPages.currentPage().getHeaders().get('Host');
String prefix = findObjectAPIName('Opportunity');
String URLL = 'https://' + hostVal+ '/'+prefix ;
Please let me know if u have any problem on same,and if this post help you please give KUDOS by click on star at left.
@Udayar - If using in VF page try this: