• car ramrod.ax1126
  • NEWBIE
  • 0 Points
  • Member since 2011

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 3
    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.

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.

Last night, we started having tests fail in our dev environment.  We have the following methods (shortened)

 



public static void updateTargetDate(...) {
     Set<Id> futureIds = new Set<Id>();
     ...
     // Add Ids
     ...
     if (!futureIds.isEmpty()) {
          updateTargetDateFromMilestone(futureIds);
     }
}

@future
public static void updateTargetDateFromMilestone(Set<Id> caseIds) {
     ...
}

 

Yesterday at noon (we run all tests in dev at noon and midnight) all the tests were running without error.  At midnight most of our tests were failing with the following error:

 

System.TypeException: Invalid conversion from runtime type SET<String> to SET<Id>

 

with a referral to the method of updateTargetDateFromMilestone(Set<Id> caseIds).  This file has not been updated since June 24th 2011.

 

So the question is, has anyone else seen this error crop up?  I know that in Apex Strings and Id "should" be interchangeable, however, it doesn't matter in this case since the Set being made is of type Id and the Set parameter for the calling method is of type Id.

  • September 30, 2011
  • Like
  • 0