• devisfun
  • NEWBIE
  • 15 Points
  • Member since 2010

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 22
    Replies

Hello,

 

I have the following query in a trigger which gathers used serial numbers for a product; this will guarantee that the serial numbers generated in this trigger will be unique:

 

Serial_Number__c[] lstSNInspReg = [select Id, Serial_Number__c from Serial_Number__c where Available_for_use__c = false limit 45000];

 

Yet when I run a test class which runs this line, I get the indicated error.  I'm not sure how this query is returning more than 50,000 rows if it's limited to 45,000.

 

Any ideas?

 

Thanks!

Hello,

 

I have the following query in a trigger which gathers used serial numbers for a product; this will guarantee that the serial numbers generated in this trigger will be unique:

 

Serial_Number__c[] lstSNInspReg = [select Id, Serial_Number__c from Serial_Number__c where Available_for_use__c = false limit 45000];

 

Yet when I run a test class which runs this line, I get the indicated error.  I'm not sure how this query is returning more than 50,000 rows if it's limited to 45,000.

 

Any ideas?

 

Thanks!

I am trying to send an email in batches when someone adds a comment to a case or someone is added as a case member. The code has simply been mofified for the content of the email. Within the sandbox the emails process correctly but when I deployed to production i got an error. First error: Attemp to de-reference a null object. Any help would be appreciated as I am new to Apex Code.

 

global class CaseEmailBatch implements Database.Batchable<sObject>
{
  global Database.QueryLocator start(Database.BatchableContext BC)
  {
    
    DateTime runDate = System.Now().addMinutes(-30);
    return Database.getQueryLocator('SELECT CreatedById,CreatedDate,Id,LastModifiedById,LastModifiedDate,MemberId,ParentId,SystemModstamp,TeamRoleId,TeamTemplateMemberId FROM CaseTeamMember WHERE CreatedDate >: runDate  ');
  }
  
  
  global void execute(Database.BatchableContext BC,List<sObject> scope)
  {
      List<Messaging.Singleemailmessage> emails = new List<Messaging.Singleemailmessage>();
         Set<ID> caseIds = new Set<ID>(); 
         for(Sobject so: scope){
           CaseTeamMember ctm = (CaseTeamMember)so; 
           String caseId = String.valueOf(so.get('ParentId'));
           caseIds.add(caseId);
           
         }
         
         List<User> users = new List<User>(); 
         users = [select id, email, name FROM User]; 
         
         Map<Id, User> uIdUserMap = new Map<Id, User>(); 
         for(User u: users)
           uIdUserMap.put(u.id, u);
         
         
         List<Case> cases = [select id, CaseNumber, Subject, Description, Account.name, Contact.name, Contact.email, Contact.phone, Origin, CreatedDate, Owner.name, Owner.email FROM Case WHERE id in:caseIds];
         Map<Id, Case> caseMap = new Map<Id, Case>(); 
         for(Case c: cases){
           caseMap.put(c.id, c);
         }
           
      for(Sobject so: scope){
         CaseTeamMember ctm = (CaseTeamMember)so; 
         Case c = caseMap.get(ctm.ParentId);
          
         Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
          mail.setTargetObjectId(ctm.memberId);
          mail.setSubject('You have been added as a Case Member :' + c.CaseNumber);
          String description; 
          if(c.Description.length() > 500){
            description = c.Description.substring(0,500);
          }
          else{
            description = c.Description;
          }
          
          mail.setPlainTextBody('Case Number: ' + c.CaseNumber + '\n' + 'Subject: ' + c.Subject + '\n' + 'Description: ' + c.Description + '\n' + '\n' + 'Account Name: ' + c.Account.Name + '\n' + 'Contact Name: ' + c.Contact.Name + '\n' + 'Contact Email: ' + c.Contact.email + '\n' + 'Contact Phone: ' + c.Contact.phone + '\n' + 'Case Origin: ' + c.Origin + '\n' + 'Date/Time Opened: ' + c.CreatedDate + '\n' + 'Owner Name: ' + c.Owner.Name + '\n' + 'Owner Email: ' + c.Owner.email + '\n' + '\n' + 'Click here to access the case directly: ' + 'https://ssl.salesforce.com/' + c.Id + '\n');
          mail.setSaveAsActivity(false);
          User u = uIdUserMap.get(ctm.CreatedById);
          mail.setReplyTo(u.email);
          mail.setSenderDisplayName(u.name);
          emails.add(mail);
      }
      
      
      List<CaseComment> cms = new List<CaseComment>();
        DateTime runDate = System.Now().addMinutes(-30);
      cms = [SELECT CommentBody, CreatedById,CreatedDate,Id,IsDeleted,IsPublished,LastModifiedById,LastModifiedDate,ParentId, Parent.CaseNumber, Parent.Description, Parent.Subject, Parent.Account.name, Parent.Contact.name, Parent.Contact.email, Parent.Contact.phone, Parent.Origin, Parent.CreatedDate, Parent.Owner.name, Parent.Owner.email, Parent.Id FROM CaseComment  WHERE CreatedDate >: runDate]; 
      Set<ID> parentIds = new Set<ID>(); 
      Map<Id, CaseComment> caseCommentMap = new Map<Id, CaseComment>(); 
      for(CaseComment cm: cms){
        caseCommentMap.put(cm.ParentId, cm);
        parentIds.add(cm.ParentId); 
        
      }
      
      List<CaseTeamMember> commentMembers = new List<CaseTeamMember>(); 
      commentMembers = [SELECT CreatedById,CreatedDate,Id,LastModifiedById,LastModifiedDate,MemberId,ParentId,SystemModstamp,TeamRoleId,TeamTemplateMemberId FROM CaseTeamMember WHERE ParentId in: parentIds]; 
      
      for(CaseTeamMember ctm: commentMembers){
        CaseComment cm = casecommentMap.get(ctm.ParentId); 
        Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
          mail.setTargetObjectId(ctm.memberId);
          mail.setSubject('A new comment has been added to Case :' + cm.Parent.CaseNumber);
          String description; 
          if(cm.Parent.Description.length() > 500){
            description = cm.Parent.Description.substring(0,500);
          }
          else{
            description = cm.Parent.Description;
          }
          
          
          mail.setPlainTextBody('Case Number: ' + cm.Parent.CaseNumber + '\n' + 'Subject: ' + cm.Parent.Subject + '\n' + 'Description: ' + cm.Parent.Description + '\n' + '\n' + 'Last Comment: ' + cm.CommentBody + '\n' + '\n' + 'Account Name: ' + cm.Parent.Account.Name + '\n' + 'Contact Name: ' + cm.Parent.Contact.Name + '\n' + 'Contact Email: ' + cm.Parent.Contact.email + '\n' + 'Contact Phone: ' + cm.Parent.Contact.phone + '\n' + 'Case Origin: ' + cm.Parent.Origin + '\n' + 'Date/Time Opened: ' + cm.Parent.CreatedDate + '\n' + 'Owner Name: ' + cm.Parent.Owner.Name + '\n' + 'Owner Email: ' + cm.Parent.Owner.email + '\n' + '\n' + 'Click here to access the case directly: ' + 'https://ssl.salesforce.com/' + cm.Parent.Id);
          mail.setSaveAsActivity(false);
          User u = uIdUserMap.get(cm.CreatedById);
          mail.setReplyTo(u.email);
          mail.setSenderDisplayName(u.name);
        
          emails.add(mail);
        
        
      }
      
      Messaging.sendEmail(emails);
      
      
      
      
  
  }
  
  global void finish(Database.BatchableContext BC)
  {
    
  }
  
}

 

I'd like to be able to kick off my query refresh "lights out" using sfQueryAll in a macro, but I still need to enter my password+token to run the query in a new Excel session. Is there a way to call the password+token in the macro so I don't have to enter it manually?

I want to include a space after Documents.   (Steps1-4 msut be...)

what do I need to do to the Style to put a white space in the string?

 

 

<apex:outputText style="font-size:9pt;font-weight:bold!important;" value="tab to Preview Required Insurance Coverages and Upload Insurance Related Documents.(Steps 1 - 4 must be completed on this tab when uploading documents) " />

 

 

 

 

 

  • September 09, 2011
  • Like
  • 0

I am having following error in apex class while reading a word document which is uploaded in Document object .

 

"BLOB is not a valid UTF-8 string".

 

Thanks,

Devendra Natani

i want to use jquery validation plugin in salesforce.


i name the id in salesforce but when it comes to html the id is changed.


exmp:

id="uname"

id="j_id0:login:uname"


pls help me to solve this problem i am not geting the out put

Hi,

I need to put a custom related list on the account detail page and put the Hover link on the top of the page for the custom related list.

 

I was able to do the custom related list displayed on the bottom of the Account detail page wiring a standard controller extension and visula force page.

 

Now the problem is How do I place the Hover link on the top of the page for the custom list? I saw couple of threads for the above, but the hover links issue was never discussed?.

 

Can any one please guide me how can I do this.

 

Thank you.