• Davinder Kaur 8
  • NEWBIE
  • 10 Points
  • Member since 2014

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 3
    Questions
  • 5
    Replies
Please tell is there any way to capture Date/Time in formuala field, On changing upon the picklist value
Hi Can anyone please help me.

I  have written a trigger which is working absolutly fine on SANDBOX, but not working on production.

trigger duperror on Sourcing_Tracker__c (before insert) {
    
        
    for(Sourcing_Tracker__c SrcTrc : trigger.new){
    List<Sourcing_Tracker__c> stList=[Select id, CreatedDate, Date_of_Sourcing__c, Date_of_Birth__c, Mobile__c from Sourcing_Tracker__c where Date_of_Birth__c=:SrcTrc.Date_of_Birth__c 
                                          And Mobile__c =:SrcTrc.Mobile__c And Date_of_Sourcing__c= LAST_90_DAYS]; 
      
              
        
        if(stList.size()>0 && SrcTrc.Date_of_Birth__c != Null && SrcTrc.Mobile__c != null){
            system.debug(stList.size());
        SrcTrc.addError('Duplicate Record');
            } 
        }
     }
I wrote a trigger to create a new case when a closed case receives a mail. It works absolutely fine on sandbox but not working on production.

trigger EmailMessageAfterUpdate on EmailMessage (after insert) {
   
// limit 1001 used, else it was giving error "System.LimitException: Too many query rows: 50001".

   List<case> caseList = [Select id, Status from Case where Status = 'Closed' limit 1001];
            for (EmailMessage newEmail : Trigger.new) 
            {     for(case cc : caseList){
                       if(cc.Status == 'Closed' && cc.id == newEmail.ParentId){ 
                            Case newCase = new Case();
                            newCase.Subject = newEmail.Subject;
                            newCase.Parent_Case__c=newEmail.ParentId;
                            newCase.Category__c = newEmail.Parent.Category__c;
                            newCase.BusinessHours = newEmail.Parent.BusinessHours;
                            newCase.Status = 'Re-Opened';
                            newCase.Sub_Status__c = newEmail.Parent.Sub_Status__c;
                            insert newCase;
                         }
                   }
             }
}
Hi Can anyone please help me.

I  have written a trigger which is working absolutly fine on SANDBOX, but not working on production.

trigger duperror on Sourcing_Tracker__c (before insert) {
    
        
    for(Sourcing_Tracker__c SrcTrc : trigger.new){
    List<Sourcing_Tracker__c> stList=[Select id, CreatedDate, Date_of_Sourcing__c, Date_of_Birth__c, Mobile__c from Sourcing_Tracker__c where Date_of_Birth__c=:SrcTrc.Date_of_Birth__c 
                                          And Mobile__c =:SrcTrc.Mobile__c And Date_of_Sourcing__c= LAST_90_DAYS]; 
      
              
        
        if(stList.size()>0 && SrcTrc.Date_of_Birth__c != Null && SrcTrc.Mobile__c != null){
            system.debug(stList.size());
        SrcTrc.addError('Duplicate Record');
            } 
        }
     }
I wrote a trigger to create a new case when a closed case receives a mail. It works absolutely fine on sandbox but not working on production.

trigger EmailMessageAfterUpdate on EmailMessage (after insert) {
   
// limit 1001 used, else it was giving error "System.LimitException: Too many query rows: 50001".

   List<case> caseList = [Select id, Status from Case where Status = 'Closed' limit 1001];
            for (EmailMessage newEmail : Trigger.new) 
            {     for(case cc : caseList){
                       if(cc.Status == 'Closed' && cc.id == newEmail.ParentId){ 
                            Case newCase = new Case();
                            newCase.Subject = newEmail.Subject;
                            newCase.Parent_Case__c=newEmail.ParentId;
                            newCase.Category__c = newEmail.Parent.Category__c;
                            newCase.BusinessHours = newEmail.Parent.BusinessHours;
                            newCase.Status = 'Re-Opened';
                            newCase.Sub_Status__c = newEmail.Parent.Sub_Status__c;
                            insert newCase;
                         }
                   }
             }
}

Posting this in order to help others who, months from now, might Google "OP_WITH_INVALID_USER_TYPE_EXCEPTION" and find this explanation.

 

We wrote an Apex trigger on the User object, to insert a custom object record anytime a user updates their Chatter status.  This was done to fulfill a client's requirement to audit all Chatter activity.

 

The trigger worked fine, until one day the client signed up some Chatter Free users.  When such a user tried to update their status, they got a pop-up with an OP_WITH_INVALID_USER_TYPE_EXCEPTION error.

 

We scratched our collective heads for awhile.  After all, Apex triggers run in "system mode," right?  That is supposed to mean that "object and field-level permissions of the current user are ignored."  And yet this trigger seemed like it was running in "user mode," enforcing restrictions based on who the current user was.

 

The root cause turned out to be that a Chatter Free user cannot be the owner of a custom object record, and SFDC by default sets the current user as a new record's first owner.  We discovered this when we realized, via experiment, that Apex triggers fired as the result of actions by Chatter Free users could definitely update an existing record, but were having problems creating records.

 

So the simple solution was to explicitly set the owner of the new record to some fully-licensed user prior to inserting it.