AgileApps Support Wiki Pre Release

Difference between revisions of "DirectoryPopup.java"

From AgileApps Support Wiki
imported>Aeric
m (Text replace - 'import static com.platform.api.Functions.*; ' to '')
 
imported>Aeric
 
Line 13: Line 13:
   {
   {
   
   
     Functions.debug(params);
     Logger.info(params, "Directory");
     String objectId = (String)params.get("object_id");
     String objectId = (String)params.get("object_id");
     if(objectId  == null )
     if(objectId  == null )

Latest revision as of 01:04, 10 September 2013

<syntaxhighlight lang="java" enclose="div">

import com.platform.api.*;


public class DirectoryPopup {

 // Initialize the custom object ID - this can be obtained after creating the object
 // Search Record
 // Functions.searchRecords(String objectId, String fields, String criteria,
 //               String sortBy, String sortOrder, String sortBy2,
 //               String sortOrder2, int offset, int numberOfRows)
 public Result search(HashMap params) throws Exception
 {

   Logger.info(params, "Directory");
   String objectId = (String)params.get("object_id");
   if(objectId  == null )
      objectId  = "";
   String sort_by = (String)params.get("sort_by");
   if(sort_by == null || sort_by.equals(""))
      sort_by = "name";
   String sort_order = (String)params.get("sort_order");
   if(sort_order == null || sort_order.equals(""))
      sort_order = "asc";
   String no_of_rows = (String)params.get("no_of_rows");
   if(no_of_rows == null || no_of_rows.equals(""))
      no_of_rows = "10";
   String offset = (String)params.get("offset");
   if(offset == null || offset.equals(""))
      offset = "0";
   String searchType = (String)params.get("searchType");
   if(searchType == null ) searchType = "name";
   String keyword= (String)params.get("keyword");
   if(keyword== null ) keyword= "";
   Result result = null;
   if(searchType != null && !searchType.equals(""))
   {
       if(keyword== null ||keyword.equals(""))
       {
         result = Functions.searchRecords(objectId, 
           "record_id,first_name,name1,address,city,state,zip,direct_phone,email", 
           "", sort_by, sort_order, "", "", 
           Integer.parseInt(offset), Integer.parseInt(no_of_rows));
       }
       else
       {
         result = Functions.searchRecords(objectId,
           "record_id,first_name,name1,address,city,state,zip,direct_phone,email",
           searchType + " contains '" + keyword+ "'", 
           sort_by, sort_order, "", "", 
           Integer.parseInt(offset), Integer.parseInt(no_of_rows));
       }
   }
   else
   {
      result = Functions.searchRecords(objectId, 
         "record_id,first_name,name1,address,city,state,zip,direct_phone,email",
         "", sort_by, sort_order, "", "", 
         Integer.parseInt(offset), Integer.parseInt(no_of_rows));
   }
   return result;
 }

} </syntaxhighlight>