You need to sign in to do that
Don't have an account?
getServerTimeStamp - How to pass value to query function
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
In very few words, I want to do the following:
1. Get Server Time (sforce) - new time
2. Save Server Time to dabase for future use - new time
3. Query sforce using Server Time using old time
4. Wait for 5 to 10 minutes.
5. Get Server Time from database - old time
6. Repeat Step (1 to 5)
When program run for first time, old time could have any value. After, that old time will be 5 to 10 minutes less than the Server Current Time.