You need to sign in to do that
Don't have an account?
How can i swap a hidden variable in the web form depending on where is the page coming from ?
For example i got a field called origin if it is coming from facebook i want to save FB and if it come from the web save the value WEB, how can i do that im pretty new ?
Thanks
Thanks
String ref = System.currentPageReference().getHeaders().get('Referer');
After getting that you can check it against a pattern to make sure its facebook or any other web...
Example:
String ref = System.currentPageReference().getHeaders().get('Referer');
if(ref == null) ref = '';
system.debug('**************Referer: ' + ref);
//In this pattern i want to get the two grouping in between the / , so i use the ( ) to separate each grouping
Pattern p = Pattern.compile('^.*\\.com/([a-z]{2})/([a-z]{2})/.*$');
Matcher m = p.matcher(ref);
if(m.Matches()) {
//FB
}else{
//WEB
}
All Answers
String ref = System.currentPageReference().getHeaders().get('Referer');
After getting that you can check it against a pattern to make sure its facebook or any other web...
Example:
String ref = System.currentPageReference().getHeaders().get('Referer');
if(ref == null) ref = '';
system.debug('**************Referer: ' + ref);
//In this pattern i want to get the two grouping in between the / , so i use the ( ) to separate each grouping
Pattern p = Pattern.compile('^.*\\.com/([a-z]{2})/([a-z]{2})/.*$');
Matcher m = p.matcher(ref);
if(m.Matches()) {
//FB
}else{
//WEB
}