0

Sorry if there are already subjects about this, didn't found anything.

Here is my problem : some records contains "&" in fields (or accents). They have to. Those fields are automatically updated and used as mapping values, so I cannot really control them.

When record is saved, "&" become "&".

Then record is updated and value become "&". Then "&" and so on ...

Correct them manyally will just do the same.

It's causing me 2 problems :

  1. my values get false (and this value is used for mapping)
  2. at some point the value is getting too large and update fails.

Example : a record with "Johns & Johns", automatically created. If a lead is created with "Johns & Johns", some apex code should value a lookup with this record. But when I save it, value becomes "Johns & Johns". Then "Johns & Johns".

Same thing with accents that are registered with html values "é" then "é" and so on.


Edit 2019-11-15 Since it could be some trigger code, i searched and found this function, the only on used on those field

public static String specialCharHandler(String f){
    String str = f.escapeHtml4();
    system.debug('str::-->>' + str);
    str = str.replace(' ',' ');
    system.debug('str22::-->>' + str);
    return str;
}

Ok, i made some tests and this is the cause of the behavior.

Thanks cropredy for helping me understand the problem. Would have vote for your comment if it was an answer ;)

  • 1
    Can you add relevant apex trigger code? – Pranay Jaiswal Nov 14 '19 at 14:43
  • 1
    something in your code is doing encoding when this is not required; SFDC text fields accept any valid UTF-8 character so extra encoding should not be required – cropredy Nov 14 '19 at 19:12
  • Ok thanks guys. That's a start. I will check it. – Guillaume Nov 15 '19 at 8:11
0

Ok found the encoding in an old apex class called by an apex trigger.

code.escapeHtml4();

Just commented it.

Thanks cropredy.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.