• ASpin
  • NEWBIE
  • 0 Points
  • Member since 2012

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 2
    Replies

I've brought this up with Premier support and keep getting told that I need to modify my code and the following issue I am having is working as intended.

 

I have this query in a User Trigger: Profile p1 = [SELECT ID from Profile WHERE Name = 'System Administrator'];

 

When the trigger fires with a user that has "English" as their language on their user record, the query returns one row, the Standard System Administrator profile.

 

When the trigger fires with a user that has "Spanish" as their language on their user record, a "System.QueryException: List has no rows for assignment to SObject" exception is thrown. That's because the API has translated "System Administrator" into "'administrador del sistema"

 

Up until this point, Salesforce is suggesting I add a "or Name =''administrador del sistema' " to my where clause or that I specifically check what locale the running user is in and execute a different query specifically for them, but neither of these seem like a reasonable solution. What if I have users that use 10 different languages? Do I really need to handle all these additional or clauses in my SOQL statements? What happens when even more additional languages are available natively?

 

I bring this up because it's not really a big deal to change the one line of code, but it is a big deal to go through all of our custom code, duplicate/modify it for each and every language, and then update all the test classes to check it. 

 

Is there a way or a function I can use to say that regardless of the user's selected langauge, always run this Trigger or Class in English?

 

Thanks in advance.