• Santo
  • NEWBIE
  • 0 Points
  • Member since 2003

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

I am trying to create a program that read data from salesforce based on the last time the data was

modified. I want to use the local time at the remote server, and save it locally. Why do I need to add 7 hours in order to get the correct results. I should be able to get the remote time, save it, and pass it to the query. Then repeat this several time.

This is the code in question:

     TimeZone.setDefault(TimeZone.getTimeZone("America/Los_Angeles"));

     String last_run_date = query_sybase("select last_run from my_time");

      //last_run_date format is   "yyyy-MM-dd'T'HH:mm:ss" + "Z"

     Calendar mycal = sforce.getServerCal();
     mycal.add(Calendar.HOUR, 7);
     sforce_time = new Timestamp(mycal.getTime().getTime());

     fields = "ActualStartofCare__c , AmbulatoryStatus__c"
         + ",Branch__c,CloseDate,CreatedById, CreatedDate"
         + ",SocialSecurity__c,StageName,SystemModstamp,TypeofCare__c";

     sql_where = "where  stagename != 'Cancelled' )"
         + " and SystemModstamp > " + last_run_date
         + " and lastmodifiedbyid != '00530000000c0nlAAA'";

     QueryResult qr;
     query = "Select " + fields + " from opportunity " + sql_where;

     qr = sforce.query(query);

      //save last_run_date to database

i've downloaded the java toolkit and set everything up as instructed. when the sample program runs, i get an error after the login:

SEARCH RESULTS
java.lang.NullPointerException
        at test.api.SForce.search(SForce.java:264)
        at test.api.SForce.main(SForce.java:399)

i put a statement in the SForce class

           for (Iterator j = element.getChildElements(); j.hasNext() {
                     SOAPElement next = (SOAPElement) j.next();
                     result = SForceUtil.getObject(next, this.typeName);
                    System.out.println("result is"+result);
                 }

which prints out "result is null" when the sample is run

my understanding is that the sample searches for accounts with the word "test" in some field. i've put the word "test" in the website field of 3 accounts.

so i'm wondering what the problem is. has anyone got the toolkit to run properly? what needs to be put in the account fields?

Message Edited by pninth on 07-01-2003 10:29 AM

Are there any java code samples available for performing a filtered query? 

Also, when can we expect to see java sample code available for download? (and why are those VB.NET and C# people the lucky ones?)