0

actually in sfdc quote i have fields quantity,price if i change the price,qunatity i want to reterview the records, id's of quotes which was quantity,price was changed may i know how can i write the query for above task, any help..

That Means i want to reterview the records from salesforce last-modified by 15mins back.. How can i reterview the records from salesforce by using soql.

  • Do you mean records last modified over the last 15 minutes i.e. ones from 0 mins ago or 5 mins ago or 7 mins ago or 15 mins ago but not ones modified before that? All SObjects have a LastModifiedDate field (that is a UTC datetime so you need to consider timezones) that you can include in the where clause of your query together with a datetime constant that your calling code creates - see e.g. blogforce9.blogspot.ie/2012/05/…. – Keith C Mar 22 '14 at 13:39
  • @keith C Can you give me query how can i get the records of every 15mins back. – Sathya Mar 22 '14 at 15:14
1

Here is some Java to create the SOQL for the query as I understand it where you want any records modified in the last 15 minutes:

int minutes = 15;
Date date = new Date(System.currentTimeMillis() - minutes * 60 * 1000);
DateFormat df = new SimpleDateFormat("yyyy-MM-dd\'T\'HH:mm:ss\'Z\'");
df.setTimeZone(TimeZone.getTimeZone("UTC"));
String soqlDate = df.format(date);
String soql = ""
        + " select Id, Quantity__c, Price__c"
        + " from Quote__c"
        + " where LastModifiedDate >= " + soqlDate
        ;
System.out.println(soql);
// ... then make web service call using the SOQL

Most of the messing around is to get the "15 minutes ago" date/time into the right format and timezone.

  • shall i use this query for SOAP APi Custom Webservice – Sathya Mar 22 '14 at 16:21
  • @Sathya I was assuming that you didn't want to do that hence doing the date logic at the client side so one of the standard SOQL APIs could be used. If you create a custom webservice you can do the calculation there in Apex instead. – Keith C Mar 22 '14 at 16:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.