function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
GeigerJTGeigerJT 

Ampersand Issue going from Sandbox to Production

I have an apex class that I am moving from the sandbox to production, and when I make the move I am having problems with the ampersand.

 

The method I use is meant to replace the character "&" with "&". In the sandbox everything tests out well and is ready for production, but when I deploy it to production my method is changed from what I have below to what appears after.

 

 

SANDBOX

 

   public string ampConverter(string ampValue){
          String ampReplace = ampValue.replace('&','&');
          return ampReplace;

 

PRODUCTION

 

    public string ampConverter(string ampValue){
          String ampReplace = ampValue.replace('&','&');
          return ampReplace;

 

 

Any ideas as to why this is happening?

GeigerJTGeigerJT

Check that:

 

I wrote the code to say

 

String ampReplace = ampValue.replace('&', '&');

 

 

However when I press save in Saleforce (or put it into production from Eclipse) it is automatically changed to 

 

String ampReplace = ampValue.replace('&', '&');

 

 

Any ideas as to why Saleforce is changing my '&' over to '&' and what I can do to fix this and keep my code the way it was written with the '&'???

Ritesh AswaneyRitesh Aswaney

If you're looking at the code in your browser, then its just the HTML rendering engine, which interprets & as the & symbol I reckon.

 

If you actually hit edit on the class, or look at the code in your IDE (refreshed from production), it should appear formatted okay.