You need to sign in to do that
Don't have an account?

How to write global variables in an APEX controller class ?
Hello,
I want to use a global variable ($Site.Prefix) in an APEX controller class, inside a condition to determine which subdomain i'm using.
For example :
Error: Compile Error: unexpected token: '{' at line ...
Since I cannot use APEX tags in my APEX class, do you know any workaround ?
Thanks.
I want to use a global variable ($Site.Prefix) in an APEX controller class, inside a condition to determine which subdomain i'm using.
For example :
urlPath = {!$Site.Prefix};However, I'm getting :
Error: Compile Error: unexpected token: '{' at line ...
Since I cannot use APEX tags in my APEX class, do you know any workaround ?
Thanks.
You need to change the code according to your class/api version,
Use the below syntax for API Version 29.0 or above
Use the below syntax for API Version 30.0 or above
Refer from the below site for more details,
http://https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_classes_sites.htm
All Answers
You can use from apex: "Site.getPrefix()"
So your code will be
urlPath = Site.getPrefix();
Thanks
You need to change the code according to your class/api version,
Use the below syntax for API Version 29.0 or above
Use the below syntax for API Version 30.0 or above
Refer from the below site for more details,
http://https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_classes_sites.htm