• Nicholas Palattao
  • NEWBIE
  • 10 Points
  • Member since 2015

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 5
    Questions
  • 5
    Replies
I have a trigger which uses UserInfo.getTimeZone() in order to obtain the GMT offset for the current user's timezone.
This offset is then compared to a timezone selected from a picklist field in order to convert a Date/Time field.

For example, if a user is in Los Angeles (GMT -08:00), and they select New York in this timezone picklist (GMT -05:00), the value of the Date/Time picklist field will be adjusted by 3 hours. 
The problem I recently discovered is that sometimes, Timezone.getOffset returns -25200000 milliseconds (-7 hours) instead of the expected -28800000 (-8 hours). This happens using the same user on different records without changing the user timezone at all. 

Because of this, many of our records have fields which are an hour off. Daylight savings time in the US does not go into effect until mid March (2017), so I don't understand how the getOffset function can be returning -7 hours so randomly.
It is highly inconsistent and I have not been able to find anything in common between records using -7 versus those using the correct number of -8. 
Any ideas or help would be greatly appreciated here.
I recently inherited my position as the only salesforce admin/developer at my company. I understand that whenever my user is listed as the 'Last Modified By' on an apex class, apex trigger, workflow or otherwise, I will receive emails detailing any error what class/trigger/process caused the error - as well and by whom, what time, etc. This information is extremely useful for the purposes of cleaning up our system, but too often I find myself unable to fully address an error because I do not receive these emails and the user under 'Last Modified By' is either an ex-employee or outside contractor from long ago. I'm wondering if there is a relatively quick and simple way to mass update all apex triggers/classes so that my user becomes 'Last Modified By'. That way I will be able to clearly understand and address all the problems that may come up throughout the system.

I wrote a small trigger to populate a lookup field on the Opportunity object, and I can't seem to get my test class to enter the loop which contains the assignment of this field. The query appears to have all the necessary info, I'm not sure what's wrong.
Here is the trigger: 
 

trigger FillPrimaryPartner on Opportunity (before insert, before update) {
    for (Opportunity opp : trigger.new){
        for (Partner p : [select id from Partner where IsPrimary=true and AccountFromId =: opp.AccountId]){
            opp.Primary_Partner__c = p.Id; 
        }
    }
}
and here is its test class:
@isTest
public class TESTFillPrimaryPartner {
	static testMethod void insertNewData(){
        
        Account partAcct = new Account();
        partAcct.Type = 'Signed Partner';
        partAcct.Industry = 'Retail';
        partAcct.BillingCountry = 'Italy';
        insert partAcct;
        
        Account oppAcct = new Account();
        oppAcct.Type = 'Customer';
        oppAcct.Industry = 'CPG';
        oppAcct.BillingCountry = 'Italy';
        insert oppAcct;
        
        Opportunity opp1 = new Opportunity();
        Opportunity.AccountId = oppAcct.Id;
        insert opp1;
        
        Partner part1 = new Partner();
        part1.IsPrimary = true;
        part1.AccountFromId = oppAcct.Id;
        part1.AccountToId = partAcct.Id;
        insert part1;
    }
}


 
I have a test class that repeatedly fails at the same point when trying to insert one specific object. Insertion of multiple other objects works fine throughout the rest of the class, and every required field has been accounted for. I'm not sure what's wrong here.
 
This is more of a general question than anything, but I recently inherited a Salesforce admin/developer position at this company and there is a high amount of clutter and errors throughout the system. What I've noticed more than anything else is the "Too many SOQL queries:101" error. It seems to stem most often from conflicts between process builder workflows and apex classes/triggers currently in production. The issue is that I did not personally write any of these classes or triggers and the error messages don't exactly give a clear solution. Basically, what are the most common causes of this error and what is (most often) the best way to resolve it?

I wrote a small trigger to populate a lookup field on the Opportunity object, and I can't seem to get my test class to enter the loop which contains the assignment of this field. The query appears to have all the necessary info, I'm not sure what's wrong.
Here is the trigger: 
 

trigger FillPrimaryPartner on Opportunity (before insert, before update) {
    for (Opportunity opp : trigger.new){
        for (Partner p : [select id from Partner where IsPrimary=true and AccountFromId =: opp.AccountId]){
            opp.Primary_Partner__c = p.Id; 
        }
    }
}
and here is its test class:
@isTest
public class TESTFillPrimaryPartner {
	static testMethod void insertNewData(){
        
        Account partAcct = new Account();
        partAcct.Type = 'Signed Partner';
        partAcct.Industry = 'Retail';
        partAcct.BillingCountry = 'Italy';
        insert partAcct;
        
        Account oppAcct = new Account();
        oppAcct.Type = 'Customer';
        oppAcct.Industry = 'CPG';
        oppAcct.BillingCountry = 'Italy';
        insert oppAcct;
        
        Opportunity opp1 = new Opportunity();
        Opportunity.AccountId = oppAcct.Id;
        insert opp1;
        
        Partner part1 = new Partner();
        part1.IsPrimary = true;
        part1.AccountFromId = oppAcct.Id;
        part1.AccountToId = partAcct.Id;
        insert part1;
    }
}


 
I have a test class that repeatedly fails at the same point when trying to insert one specific object. Insertion of multiple other objects works fine throughout the rest of the class, and every required field has been accounted for. I'm not sure what's wrong here.
 
This is more of a general question than anything, but I recently inherited a Salesforce admin/developer position at this company and there is a high amount of clutter and errors throughout the system. What I've noticed more than anything else is the "Too many SOQL queries:101" error. It seems to stem most often from conflicts between process builder workflows and apex classes/triggers currently in production. The issue is that I did not personally write any of these classes or triggers and the error messages don't exactly give a clear solution. Basically, what are the most common causes of this error and what is (most often) the best way to resolve it?