• hermi
  • NEWBIE
  • 0 Points
  • Member since 2010

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

HI,

I am trying to develop a batch class where i need to query the value of a date field, but i am getting the following error. Please help.

 

date newdate=system.today()+6;
 
//String targetDate = targetDateval.format('yyyy-MM-dd')+'T'+targetDateval.format('HH:mm:ss')+'Z'; 
system.debug(' Date'+newdate);
query= 'Select recordtypeid,ispersonaccount,id,ownerid,Date_to_Call__c from Account';
query+= ' Where Date_to_Call__c ='+'\''+newdate+'\'' +' or Date_to_Call__c = today   ';
Error:  value of filter criterion for field 'Date_to_Call__c' must be of type date and should not be enclosed in quotes
if i dont enclose it in quotes and if i just give the query as following, i am getting other error
query= 'Select recordtypeid,ispersonaccount,id,ownerid,Date_to_Call__c from Account';
 query+= ' Where Date_to_Call__c ='+newdate+' or Date_to_Call__c = today   ';
error: line 1:277 no viable alternative at character ' '
Please suggest any ideas..
  

 

  • May 11, 2011
  • Like
  • 0

HI,

I am trying to develop a batch class where i need to query the value of a date field, but i am getting the following error. Please help.

 

date newdate=system.today()+6;
 
//String targetDate = targetDateval.format('yyyy-MM-dd')+'T'+targetDateval.format('HH:mm:ss')+'Z'; 
system.debug(' Date'+newdate);
query= 'Select recordtypeid,ispersonaccount,id,ownerid,Date_to_Call__c from Account';
query+= ' Where Date_to_Call__c ='+'\''+newdate+'\'' +' or Date_to_Call__c = today   ';
Error:  value of filter criterion for field 'Date_to_Call__c' must be of type date and should not be enclosed in quotes
if i dont enclose it in quotes and if i just give the query as following, i am getting other error
query= 'Select recordtypeid,ispersonaccount,id,ownerid,Date_to_Call__c from Account';
 query+= ' Where Date_to_Call__c ='+newdate+' or Date_to_Call__c = today   ';
error: line 1:277 no viable alternative at character ' '
Please suggest any ideas..
  

 

  • May 11, 2011
  • Like
  • 0

I am a begginer at this and wrote a simple trigger to grab the Profile ID of a Lead owner and store it under a custom field.  It is below:

 

 

trigger ProfileIDCopy on Lead (before Insert, before Update) {

    for(Lead x : Trigger.New){

        // Confirm owner is not a Queue then map Profile ID to custom field
        if( ((String)x.OwnerID).substring(0,3) == '005' ){
            x.Owner_Profile_ID__c = x.Owner.Profile.ID;
        }
        else{
            // If not above, mark as queue
            x.Owner_Profile_ID__c = 'Queue';
        }
    }

}

 

The trigger saves, but it does not actually work when I test it.  The Owner_Profile__ID does not get populated.  My guess is that "Owner.Profile.ID" is not a proper call, but the fact that it saves with no error is not reassuring.  Could someone please offer some guidance?  Thanks in advance!

 

Hi

 

I am trying to write a test class for the following controller. Here is my controller

 

public class CAFApprovalHistoryController {
    public String cafId {get;set;}
    public List<ProcessInstanceHistory> getApprovalSteps() {
      If (cafId != null) {
        CAF__c cafs = [Select Id, Name, CAPEX_Total__c, Off_Net_Circuit_Expense_Total__c, CAF_IRR__c, of_Revisions__c, Sales_Rep__c, Sales_Manager__c, Account__c, CAF_Title1_del__c, CAF_1__c, Products_Requested__c, Bandwidth__c, Notes_of_Consideration__c, CAF_Link__c, (Select TargetObjectId, SystemModstamp, StepStatus, RemindersSent, ProcessInstanceId, OriginalActorId, IsPending, IsDeleted, Id, CreatedDate, CreatedById, Comments, ActorId From ProcessSteps order by SystemModstamp desc) from CAF__c where Id = :cafId];
        return cafs.ProcessSteps;
      }
      return new List<ProcessInstanceHistory> ();
    } 
   }

 

Here is the test class i wrote and this the error it is throwing Error: Compile Error: line breaks not allowed in string literals at line 8 column -1. I mentioned the line 8 in Red

 

 

public class TestCAFApprovalHistory
{
    public static testMethod void testCAFApprovalHistory() 
         {      
        Test.startTest();
        PageReference result = Page.CAFApprovalHistory;
        Test.setCurrentPage(result);               
        CAF__c cf = new CAF__c(Name='Test', CAPEX_Total__c='$1000.00', Off_Net_Circuit_Expense_Total__c='$1000.00, CAF_IRR__c='25%', of_Revisions__c='0', Sales_Rep__c='Test', Sales_Manager__c='TestTest', Account__c='Test Account');
        insert cf;
        }
        }