• divyajain1
  • NEWBIE
  • 0 Points
  • Member since 2011

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

HI,

 

I am trying to run aggregrated results query from a java application. The examples say to use getField from aggreagret results to extract the fields  but for me it is giving a compilation error saying that getField is not defined for AggreagtedResult class. Is it something that was introduced later. My API version is 20.0

 

My java example

QueryResult qr = binding.query("select leadsource, count(name) total, count(state) from lead group by leadsource");
            if (qr.getSize() > 0) {
                        for (int i = 0; i < qr.getRecords().length; i++) {
                               System.out.println(" class : " + qr.getRecords(i).getClass());
                             
                               AggregateResult ar = (AggregateResult)qr.getRecords(i);
                               System.debug(ar.getField("leadsource")+"-"+ar.getField("total")+"-"+ar.getField("expr0"));

                      }

}

 

Is there some other way to extract this information.

 

Thanks,

HI,

 

I am trying to get the reports data in salesforce.com to our application using the webservices /RestAPI.  I dont see any Reports API to get the data in the csv or XML format (like we get when we export the report using the salesforce UI.)

 

If there is a way to do it, please let me know.

 

Thanks,

Divya.

HI,

 

I am trying to build an application where I need to get the default  search fields that are avaliable to the  on salesforce.com when he does the search. Is there a way to get these settings for all object types , even the one that have not been customized? I was trying to get the SearchLayout object using Metadata API but it gives me an Unknown Type error. Any help/ suggestion on how to retrieve these settings.

 

Thanks,

Divya.

HI,

 

I am trying to get the list of all Reports defined in salesforce.com using webservices/metatdata APIs. To get the report list,  I am using metadata APIs to first retrive the list of Report Folders ( looks it is needed to get the list of reports).

 

When I run my program, I am only getting the list of folders that I have created and "unfiled$public" folder. I am not getting folders like "Activity Reports" Folder, "Lead Reports" etc. I have verified that the permisions on these report folders are same the folder created by me, i.,e. "accessible to all users."

 

Please let me know if I need to enable any other particular settings or if the following way to get this lists incorrect.

 

Thanks,

Divya.

 

String component = "ReportFolder";
         ListMetadataQuery query = new ListMetadataQuery();
         query.setType(component);
          FileProperties[] results = metadatabinding.listMetadata( new ListMetadataQuery[] {query}, 20.0);
          if (results != null) {
           for (FileProperties n : results) {
                System.out.println("Component fullName: " + n.getFullName());
                System.out.println("Component type: " + n.getType());
            }
        }  else {
            System.out.println(" results is null");
        }

 

HI,

 

I am trying to use REST APIs and I am stuck at the first step of authorization itself. I have build the following JSP and created a remoteaccess setup using my developer account.  my jsp keeps failing with the following error

 

responseBody : {"error":"invalid_client_credentials","error_description":"client secret invalid"}

 

I have verified that the client_id, client_secret and redirecturl in my JSP are same as the one on the salesforce setup page.

MY JSP code is as follows. ( For the post I have replaced my client_id, client secret and redirecturl with madeup values.) Please let me know what am I doing wrong. 

Any help is appreciated.

Thanks,

Divya.

 

<%@ page language="java" contentType="text/html; charset=ISO-8859-1"%>
<%@ page import="org.apache.commons.httpclient.*,
                org.apache.commons.httpclient.cookie.*,
                org.apache.commons.httpclient.methods.*,

                java.net.URLEncoder"
%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>My Title</title>
</head>
<body>

 

<%

String responseBody = null;
 try{

   java.util.Date d = new java.util.Date();
    System.out.println(" trying at date: " + d);
    String redirectUri="https://<myserver>/salesforce_callback.jsp";

    String clientId = "<myclientid>";

    String clientSecret="<myclientsecret>";

    String encodeduri=URLEncoder.encode(redirectUri,"UTF-8");

 

    // if code is null, go to authorization url first. did it one time

    String code= request.getParameter("code");
    if( code == null || code.trim().length() == 0 ) {
        String authurl= "https://login.salesforce.com/services/oauth2/authorize?response_type=code"+
                "&client_id="+clientId+
                  "&redirect_uri="+encodeduri;
             System.out.println(" code is null :" + authurl);
            response.sendRedirect(authurl);
     } else {    
      System.out.println(" code is not null : " + code);
    // create the post request with all the params as described.
    HttpClient httpclient = new HttpClient();
    PostMethod post = new PostMethod("https://na1.salesforce.com/services/oauth2/token");
    post.addParameter("code",code);
    post.addParameter("grant_type","authorization_code");
    post.addParameter("client_id",clientId);
    post.addParameter("client_secret",clientSecret);
    post.addParameter("redirect_uri",redirectUri);
    

 

     // finally send the request to get the token
       httpclient.executeMethod(post);
     System.out.println(" after sending response : ");
      responseBody = post.getResponseBodyAsString();
     System.out.println(" responseBody : " + responseBody);
  }
%>
<h1>

Response : <%=responseBody%>
</h1>


<%
   } catch (Exception e) {
            e.printStackTrace();
         }
 %>
</body>
</html>

 

 

 

HI,

 

I am trying to build an application where I need to get the default  search fields that are avaliable to the  on salesforce.com when he does the search. Is there a way to get these settings for all object types , even the one that have not been customized? I was trying to get the SearchLayout object using Metadata API but it gives me an Unknown Type error. Any help/ suggestion on how to retrieve these settings.

 

Thanks,

Divya.

HI,

 

I am trying to get the list of all Reports defined in salesforce.com using webservices/metatdata APIs. To get the report list,  I am using metadata APIs to first retrive the list of Report Folders ( looks it is needed to get the list of reports).

 

When I run my program, I am only getting the list of folders that I have created and "unfiled$public" folder. I am not getting folders like "Activity Reports" Folder, "Lead Reports" etc. I have verified that the permisions on these report folders are same the folder created by me, i.,e. "accessible to all users."

 

Please let me know if I need to enable any other particular settings or if the following way to get this lists incorrect.

 

Thanks,

Divya.

 

String component = "ReportFolder";
         ListMetadataQuery query = new ListMetadataQuery();
         query.setType(component);
          FileProperties[] results = metadatabinding.listMetadata( new ListMetadataQuery[] {query}, 20.0);
          if (results != null) {
           for (FileProperties n : results) {
                System.out.println("Component fullName: " + n.getFullName());
                System.out.println("Component type: " + n.getType());
            }
        }  else {
            System.out.println(" results is null");
        }