• nick1505
  • NEWBIE
  • 125 Points
  • Member since 2012

  • Chatter
    Feed
  • 5
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 27
    Replies

Hello

 

I have written the code below for case escalation i am getting an exception for it can someone please help me out

 

Thanks!

 

Code is :

 

global class CaseEscalation  implements  Database.Batchable<SObject> 
{
global CaseEscalation()
{
}  
     global Database.QueryLocator start(Database.BatchableContext  ctx)
     {
         return Database.getQueryLocator([SELECT  CaseNumber, CreatedDate,Status FROM Case where CreatedDate<Today and Status!='Closed']);  
     }
      
      
     global void execute(Database.BatchableContext ctx, List<Sobject> scope)
     {
       
       List<Case> ca = (List<Case>)scope;
       //List <Case> ca =  new List<Case>();
       //for(SObject so :scope)
       //{
       //    Case c = (Case)so;
        //   ca.add(c);
       //}    
       System.debug('checking======='+ca);
       for(Case c : ca)
       {                      
           // Double Days = Math.Floor((System.now().getTime()  - c.CreatedDate.getTime())/ (1000.0*60.0*60.0*24));                       
            //if(Days > 1  &&  c.Status != 'Closed' )
             //{
                System.Debug(c);
                 String emailMessage = 'The case  ' + c.CaseNumber + ' has been ecalated ' + ' Please look into the case ' + 'Thankyou';
                 Messaging.SingleEmailMessage mail  =   new Messaging.SingleEmailMessage();
                 String[] toAddresses = new String[] {'reems.agarwal3@gmail.com'};
                 mail.setToAddresses(toAddresses);
                 mail.setSubject('Case Escalation');
                 mail.setPlainTextBody(emailMessage);
                 Messaging.sendEmail(new Messaging.SingleEmailMessage[]{ mail });
                 c.Status = 'Escalated';
            // }
        }
if(ca.size()>0)
        update ca;
           }
   
    global void finish(Database.BatchableContext ctx)
    {
    }


}

 

I am getting the following exception:

 

Apex script unhandled exception by user/organization: 005U0000000DmS9/00DU0000000HTCU

Failed to process batch for class 'CaseEscalation' for job id '707U0000004bzCe'

caused by: System.LimitException: Too many Email Invocations: 11

Class.CaseEscalation.execute: line 35, column 1

I need to write an apex trigger that takes information from some of the Contact fields and uses them to generate a value for a custom field. 

 

For example, say I have a custom field called "Area Code." When I create a new contact, after filling out the Mobile field and click save, the trigger should fire and (using apex code i would write) populate the Area Code field with the first three numbers from the Mobile field. 

 

The problem is that the triggers I write don't seem to fire correctly - when the record is saved, nothing happens, or I have to edit the Mobile field and save it again in order for the trigger to work. I don't really need to know how to make an area code field, but I do need to do something similar. How can I make a trigger that fires correctly when a record is created or edited?

Hi ,

 

I have created a class in sand box without test class and it is working properly but as per the my requirement I want to inactive this class for a while but I am not able to do it it is throwing error.

 

Hello everyone,

 

 

In a  database batchable...How do I put a 5 records limit to the scope? 

 

global void execute(Database.BatchableContext info, List<Contact> scope)

 

 

Thanks in advance!

public class AllNewWelcomeLetter{

List<mbMemberAC__c> memberac;

public AllNewWelcomeLetter() {

}

List<Attachment> att;

public PageReference savePdf() {

memberac=[select id,MEnrollmentDate__c,Member_A_C_Client_name__c,Member_Chinese_Name__c,PRIVE_ADDR1__c,PRIVE_ADDR2__c,PRIVE_ADDR3__c,PRIVE_ADDR4__c,name from mbMemberAC__c where WelcomeLetterSenton__c=:null and MEnrollmentDate__c!=:null and MemberStatus__c=:'Active' ];

if(memberac.size()>0){

for(mbMemberAC__c mem:memberac){
//search the pdf name from attachment and judge if the old name is same as the new pdf name,pdf in present memAC is unique
att=[select Name from Attachment where ParentId =:mem.id and name=:mem.Member_A_C_Client_name__c+'.pdf'];

if(att.size()==0){

PageReference pdf = Page.WelcomeLetterForEach;

pdf.getParameters().put('id',mem.id);

Attachment attach = new Attachment();

// the contents of the attachment from the pdf
Blob body;

try {
// returns the output of the page as a PDF
body = pdf.getContent();

// need to pass unit test -- current bug
} catch (VisualforceException e) {
body = Blob.valueOf('Some Text');
}

attach.Body = body;
attach.Name = mem.Member_A_C_Client_name__c+'.pdf';
attach.IsPrivate = false;
// attach the pdf to the account
attach.ParentId =mem.id;
insert attach;

mem.WelcomeLetterSenton__c=date.today();
update mem;
}
}
}else{
ApexPages.Message myMsg = new ApexPages.Message(ApexPages.Severity.FATAL, '(error):The object memshipAC is null!');
ApexPages.addMessage(myMsg);
return page.WelcomeLetterPage;

}

return page.ListMembershipAC;
}

}

if i change the number 100 into 10 or less in method savePDF() , then it's ok! otherwise ,there will be the error message occurred,can you tell me how can i solve it. thank you very much!! 

 
  • May 09, 2012
  • Like
  • 0

Hello

 

I have written the code below for case escalation i am getting an exception for it can someone please help me out

 

Thanks!

 

Code is :

 

global class CaseEscalation  implements  Database.Batchable<SObject> 
{
global CaseEscalation()
{
}  
     global Database.QueryLocator start(Database.BatchableContext  ctx)
     {
         return Database.getQueryLocator([SELECT  CaseNumber, CreatedDate,Status FROM Case where CreatedDate<Today and Status!='Closed']);  
     }
      
      
     global void execute(Database.BatchableContext ctx, List<Sobject> scope)
     {
       
       List<Case> ca = (List<Case>)scope;
       //List <Case> ca =  new List<Case>();
       //for(SObject so :scope)
       //{
       //    Case c = (Case)so;
        //   ca.add(c);
       //}    
       System.debug('checking======='+ca);
       for(Case c : ca)
       {                      
           // Double Days = Math.Floor((System.now().getTime()  - c.CreatedDate.getTime())/ (1000.0*60.0*60.0*24));                       
            //if(Days > 1  &&  c.Status != 'Closed' )
             //{
                System.Debug(c);
                 String emailMessage = 'The case  ' + c.CaseNumber + ' has been ecalated ' + ' Please look into the case ' + 'Thankyou';
                 Messaging.SingleEmailMessage mail  =   new Messaging.SingleEmailMessage();
                 String[] toAddresses = new String[] {'reems.agarwal3@gmail.com'};
                 mail.setToAddresses(toAddresses);
                 mail.setSubject('Case Escalation');
                 mail.setPlainTextBody(emailMessage);
                 Messaging.sendEmail(new Messaging.SingleEmailMessage[]{ mail });
                 c.Status = 'Escalated';
            // }
        }
if(ca.size()>0)
        update ca;
           }
   
    global void finish(Database.BatchableContext ctx)
    {
    }


}

 

I am getting the following exception:

 

Apex script unhandled exception by user/organization: 005U0000000DmS9/00DU0000000HTCU

Failed to process batch for class 'CaseEscalation' for job id '707U0000004bzCe'

caused by: System.LimitException: Too many Email Invocations: 11

Class.CaseEscalation.execute: line 35, column 1

Can anyone tell me the proper difference b/w trigger.old and trigger.new with eg's?

 

I dont want the help n training explanation

Hi

Can any body please explain me, what is dashboard  in salesforce? And how to use it. If possible please also provide any link available.

 

Thanks

Anu

Hi there,

               i need a table with 4 columns and 3 rows with manual entry of data and i wrote a code like this

 

<apex:pageBlockSection title="EDUCATION">
  <table border="1">
     <tr>
      <td>College/University</td>
      <td>Year Granted</td>
      <td>Degree Granted</td>
      <td>Major</td>
     </tr>
     <tr>
      <td><input type="text" value="{!e.College_University__c}"/></td>
      <td><input type="text" value="{!e.Year_Granted__c}"/></td>
      <td><input type="text" value="{!e.Degree_Granted__c}"/></td>
      <td><input type="text" value="{!e.Major__c}"/></td>
     </tr>
     <tr>
      <td><input type="text" value="{!e.College_University1__c}"/></td>
      <td><input type="text" value="{!e.Year_Granted1__c}"/></td>
      <td><input type="text" value="{!e.Degree_Granted1__c}"/></td>
      <td><input type="text" value="{!e.Major1__c}"/></td>
     </tr>
     <tr>
      <td><input type="text" value="{!e.College_University2__c}"/></td>
      <td><input type="text" value="{!e.Year_Granted2__c}"/></td>
      <td><input type="text" value="{!e.Degree_Granted2__c}"/></td>
      <td><input type="text" value="{!e.Major2__c}"/></td>
     </tr>
     
  </table>   
   
</apex:pageBlockSection>

 

 

i got a table with 3 empty rows,

now i need to bind these row values to fields in object,how can i do that can any one suggest me.

 

 

I want a trigger:

where if the phone number starts with  011 it automatically takes delhi as a city
how can i achieve this? 

Hi, Experts - During client merge we have a need to retain a custom field value from deleted client onto retained client. Can this be done with standard SF features or we need custom Apex ? Example: Client A merges into client B Client record has 2 custom fields LID, LID_After_Merge After A merges into B; client B LID_After_Merge field gets the value of LID (of Client A) With trigger, how to detect a merge took place ? Thanks,

I need to write an apex trigger that takes information from some of the Contact fields and uses them to generate a value for a custom field. 

 

For example, say I have a custom field called "Area Code." When I create a new contact, after filling out the Mobile field and click save, the trigger should fire and (using apex code i would write) populate the Area Code field with the first three numbers from the Mobile field. 

 

The problem is that the triggers I write don't seem to fire correctly - when the record is saved, nothing happens, or I have to edit the Mobile field and save it again in order for the trigger to work. I don't really need to know how to make an area code field, but I do need to do something similar. How can I make a trigger that fires correctly when a record is created or edited?

We have many classes on our org, some of them were developed many years ago and there is one that it looks like is a bit outdated and has 0 % code coverage, I have the feeling that is not in use and could be deleted, is there any way to check if this class is in invoked by a trigger or anywhere else?

 

Thanks.

I'm getting the "Schedulable class has jobs pending or in progress" error on about sixty classes in my deployment package.  Almost all, if not all of these are not scheduled.  I do have six scheduled jobs but they run other classes.  Also, I know many of the classes in my deployment aren't referred to by classes that are scheduled directly or indirectly.

 

Is SF now not letting you deploy any classes if you have jobs scheduled?

 

 

H,

 

When i am trying to delete some records from object,  i am getting this error  'Too many query rows 50001'. I have used the limit as 50000 in query. Still i am facing the same problem. How can i solve this issue.

 

I have used the limit in my query like as

 

for(store__C ss:[select id,Retail_Brand__c from store__C where Retail_Brand__c =:rid limit 50000])
setsid.add(ss.id);
For(StoreProduct_category__C spc:[select id,store__c,Product_category__C from StoreProduct_category__C where Store__c in : setsid limit 50000])
{
delspclist.add(spc);
system.debug(delspclist.size()+'del===');
}
if(delspclist.size()>0){
deletestoreproducts del=new deletestoreproducts(delspclist);
database.executebatch(del,1000);

 

I am getting the error at  the line, which is bold in my code.

 

Thanks

Hello Board,

 

I am working in Sandbox where I have installed the managed package application. I have changed the field labels using Transalation Workbench option.

 

Now I would like to send these label changes into the Production Org.

 

How can I send these label changes using "ChangeSets"?

 

Is there any other way to send these label changes from Sandbox to Production Org?

 

Thanks,
Devendra

Hello everyone,

 

 

In a  database batchable...How do I put a 5 records limit to the scope? 

 

global void execute(Database.BatchableContext info, List<Contact> scope)

 

 

Thanks in advance!

Hi guys, I created a visualforce email template but I'm Stack with the error that says "Object row was retrieved via SOQL without querying the requested field: Task.Status"

 

I'm stack with this one I need your help please.

 

Below are the Complete codes:

 

<messaging:emailTemplate recipientType="Contact"
relatedToType="Calls__c"
subject="Meeting Minutes: {!relatedTo.Account__r.name}-{!relatedTo.Call_Date__c}"
replyTo="support@acme.com">
<messaging:htmlEmailBody >
<html>
<style type="text/css">
body{

border-width: 2px;
border-style: dashed;
border-size: 2px;
border-color: blue;
background-color: #CCCCCC;
}

table
{
border-width: 5px;
border-spacing: 5px;
border-style: dashed;
border-color: #FF0000;
background-color: #FFFFFF;
}
td
{
border-width: 1px;
padding: 4px;
border-style: solid;
border-color: #000000;
background-color: #FFEECC;
}
th
{
color: #000000;
border-width: 1px ;
padding: 4px ;
border-style: solid ;
border-color: #000000;
background-color: #FFFFF0;
}

</style>
<body>

<apex:image id="Logo" value="https://bluescope--bsldevsb--c.cs6.content.force.com/servlet/servlet.FileDownload?file=015N00000008vTW" height="64" width="90"/>
<table border="2">
<center>
<p>Meeting Minutes with {!relatedTo.Account__r.name},</p>
</center>
<p>Meeting Date &nbsp; &nbsp;<apex:outputText value="{0,date,M/d/yyyy }"> <apex:param value="{!relatedTo.Call_Date__c}" /> </apex:outputText> .</p>
<p>Location: {!relatedTo.Location__c}.</p>
<p>BlueScope Steel representative: {!relatedTo.Owner.Name}.</p>

<p/><p/>
<p>Meeting Summary:
{!relatedTo.Meeting_Summary__c}
</p>

<p/><p/><p/>

<center><b>Open Activities</b></center>
<center>
<table border="2">
<tr>
<th>Owner</th>
<th>Subject</th>
<th>&nbsp;&nbsp;ActivityDate</th>
<th>&nbsp;&nbsp;Status</th>
</tr>
<apex:repeat value="{!relatedTo.Tasks}" var="cx">
<tr>
<td style="text-align:right; display:{!if (cx.Status=='Completed' && cx.Visible_to_Customer__c==true,'none','table-column')}">{!cx.Owner.name}</td>
<td style="text-align:right; display:{!if (cx.Status=='Completed' && cx.Visible_to_Customer__c==true,'none','table-column')}">{!cx.Subject}</td>
<td style="text-align:right; display:{!if (cx.Status=='Completed' && cx.Visible_to_Customer__c==true,'none','table-column')}"><apex:outputText value="{0,date,M/d/yyyy }"> <apex:param value="{!cx.ActivityDate}" /> </apex:outputText></td>
<td style="text-align:right; display:{!if (cx.Status=='Completed' && cx.Visible_to_Customer__c==true,'none','table-column')}">&nbsp;&nbsp;{!cx.Status}</td>
</tr>
</apex:repeat>
</table>
</center>

<p>
Should you have any questions, please feel free to contact me.
</p>
<p>
Regards,
</p>
{!relatedTo.Owner.Name}
<p/>
<center>
<apex:outputLink value="http://www.salesforce.com">
For more detailed information login to Salesforce.com
</apex:outputLink>
</center>
</table>
</body>
</html>
</messaging:htmlEmailBody>
</messaging:emailTemplate>