8 Replies Latest reply on Aug 20, 2012 8:17 AM by LJ LongWing

    How to retrieve entries from a form based on a date qualification?

      Share This:

      Hi,

       

       

                   I want to retrieve records from the form which have are between are certain date range. Right now I have something like this.

       

       

       

      import com.bmc.arsys.api.*;

      import java.util.*;

      import java.io.*

      ;public class getListEntryWithFields {

       

       

                          public static void main(String[] args) {

       

                                    callMethod();

                          }

       

                          public static ArrayList callMethod(){

                                    String user = new String("sthakkar");

                                    String server = new String("bsmprod");

                                    String formname = new String("CUS-CWW:Alert");

                                    String pass = new String("pass");

                                    File file = new File("c://suraj.txt"); 

       

                                     

                                    // Write each string in the array on a separate line 

       

                                    String[] words=new String[10000];

                                    //Declaring Integer as well as Integer Array Variables

                                    int firstRetrive = 0;

                                    int maxRetrive= 1000;

                                    int[] entrylist={83008076};

       

       

                                    //Declaring Boolean Variables

                                    boolean uselocale= false;

       

                                    //Declaring Object Variables

                                    QualifierInfo qual = new QualifierInfo();

                                    List<SortInfo> sort = new LinkedList<SortInfo>();

                                    OutputInteger outint = new OutputInteger();

                                    //List<Entry> entrylistdata = new LinkedList<Entry>();

                                    List<Entry> entrylistdata = new LinkedList<Entry>();

       

                                    ARServerUser contxt = new ARServerUser(user,pass,"",server);

                                    try{

       

                                              }

                                              catch(Exception e)

                                              {}

                        try

                        {

                                  entrylistdata=contxt.getListEntryObjects(formname, qual, firstRetrive, maxRetrive, null, entrylist, uselocale, outint);

                        

                        

                                  ListIterator<Entry> it1 = entrylistdata.listIterator();

                                  int i=0;

                                  while (it1.hasNext())

                                  {

                                                      Entry ent = it1.next();

                        

                                                      Iterator<Map.Entry<Integer, Value>> intit = ent.entrySet().iterator();

                                                      while (intit.hasNext())

                                                      {

                                                       words[i]=intit.next().toString();

                                                      

                                                       i++;

                        

                                                      }

                                                      System.out.println(i);

                                  }

                        

                        }

                        catch (ARException e)

                        {

                                  System.out.println("Error occured" + e.getMessage());

                                  System.out.println(words.length);

                        

                        }

                        try{

                                  PrintWriter out1 = new PrintWriter(new FileWriter(file));

                                  for (int y=0;y<words.length;y++){

                                            out1.println(words[y]);

                                  }

                        }

                        catch(Exception e){}

                     

                        System.out.println(entrylistdata);

                        System.out.println(words.length);

                        return new ArrayList(entrylistdata);

       

       

                          }

       

       

       

      }

       

      This gives me all the records in the form but i need to provide a date range as my qualifier. For example

       

      "Fetch all records from this form which are between 1st July 2008 - 1 August 2008" I have both the date fields in my form and when I use get entrylist it gives me the timestamp.

      Can someone please help.

       

      Thanks a lot,

      Suraj