• LaurentDel
  • NEWBIE
  • 0 Points
  • Member since 2010

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 3
    Questions
  • 6
    Replies

Hi,

 

I am developing a Java application talking to Salesforce with the WebService API. I have generated my Java library from the Entreprise WSDL with wsc-20.jar.

I got my connection running and the user is now logged in without a problem. I request a Document and am now trying to get the Body in a String.

I cannot understand what to do with byte[] we get from object.getBody().

It says in the documentation:
"Required. Encoded file data. If specified, then do not specify a URL."
And then for type base64:
"Base 64-encoded binary data. Fields of this type are used for storing binary files in Attachment records, Document records, and Scontrol records. In these objects, the Body or Binary field contains the (base64 encoded) data, while the BodyLength field defines the length of the data in the Body or Binary field. In the Document object, you can specify a URL to the document instead of storing the document directly in the record."

So I understand that the data in the body of the document is encoded in base64. So I need to decode it.

I found this method provided by Salesforce:
com.sforce.ws.util.Base64.decode

I also found examples of:
org.apache.commons.codec.binary.Base64

I tried both ways and I still can't get my file's content right.

Here is my code:

 

public void queryRecords() {
		QueryResult qResult = null;
		  try {
		    String soqlQuery = "SELECT name, body, BodyLength, Type FROM Document LIMIT 10";
			qResult = connection.query(soqlQuery);
			boolean done = false;
			if (qResult.getSize() > 0) {
			  System.out.println("Logged-in user can see " + 
			      qResult.getRecords().length + 
			      " Document records."
			  );
			  while (! done) {
			    SObject[] records = qResult.getRecords();
			    for ( int i = 0; i < records.length; ++i ) {
			    	Document con = (Document) records[i];
				    String fName = con.getName();
				    int bodyLength = con.getBodyLength();
				    String type = con.getType();
				    System.out.println("Doc name " + (i + 1) + ": " + con.getName() + " - bodyLength: "+bodyLength+" - type: "+type);
				    
				    System.out.println("Doc body " + (i + 1) + ": " + con.getBody());
				    System.out.println("Doc body " + (i + 1) + ": " + con.getBody().toString()); 
				    System.out.println("Doc body sf" + (i + 1) + ": " + com.sforce.ws.util.Base64.decode(con.getBody()) );
				    System.out.println("Doc body sf 2" + (i + 1) + ": " + com.sforce.ws.util.Base64.decode(con.getBody()).toString() );
				    
				    String decodedResult = Base64.decodeBase64(con.getBody()).toString();
				    System.out.println("Doc body commons decode" + (i + 1) + ": " + org.apache.commons.codec.binary.Base64.decodeBase64(con.getBody()));
				    System.out.println("Doc body commons decode" + (i + 1) + ": " + decodedResult);
				    
				    String decodedResult2 = con.getBody().toString();
				    System.out.println("Doc body " + (i + 1) + ": " + decodedResult2);
				    
			    }
			    if (qResult.isDone()) {
			        done = true;
			    } else {
			        qResult = connection.queryMore(qResult.getQueryLocator());
			    }
			  }
			} else {
			  System.out.println("No records found.");
			}
			  System.out.println("\nQuery succesfully executed.");
		  } catch (ConnectionException ce) {
		    ce.printStackTrace();
		  }
	}

 

 

I would be really grateful if you could give me any advice.

Cheers,
Laurent

Hi everyone,

 

We are trying to set up Hudson in integration with Salesforce but we had some troubles around the fact that APEX is not Java. Anyone who could answer any of these questions would be of a high help:

 

 - Are you aware of any work around this?

- What is the best Continuous integration for Salesforce (Hudson, Continuum, Cruise control ect...)?

- Is there any plugin especially for Salesforce?

- Any other way of controlling quality in Salesforce code? (reports, automatic emails, batch analyzis ect...) We would be thankful for any information around quality control and Salesforce.

 

Cheers,

Laurent

Hi,

 

I would like to know the Profile permission for a User to be able to Manage a Custom Settings.

Right now my User can click on Manage, then New but when he clicks on Save this message appears:

 

 

  Insufficient Privileges
You do not have the level of access necessary to perform the operation you requested. Please contact the owner of the record or your administrator if access is necessary. 

 

Cheers,

 

Laurent

Hello,

 

Over the weekend, our sandbox was upgraded to Winter '12, and many of my Apex tests have failures now.

 

For instance, I have a test that tries to save a Lead without a Last Name (which should lead to an error for a required field missing).

 

My test:

 

static testMethod void testExceptionsConvertCloseNoLead() { 
  myGenHelpers gh = new myGenHelpers();
		
  Lead testLead = gh.getUptimeTestLead();
  insert testLead;
	            	
  testLead.LastName = null;
	            	
   myLeadConvertCloseExtension lcc = new myLeadConvertCloseExtension(new ApexPages.StandardController(testLead));
   lcc.save();
}

 

Last week, and still in production, this test passes successfully.  However, today, it fails.

 

The problem is in this code segment:

 

                try {
	                update this.myLead;
                } catch (DmlException e) {
                    for (Integer i = 0; i < e.getNumDml(); i++) {
				    	System.debug('myClass.save: error: ' + e.getDmlMessage(i));
                        this.myLead.addError(e.getDmlMessage(i)); 
                    }
                    return null;
                }

 

Instead the error being handled gracefully, the test just fails at the upsert.

 

Any thoughts?

I am getting the following error (repeated for multi objects) during deployment from Sandbox to Sandbox (We are deploying using Ant).:

Error: workflows/Account.workflow(414,12):This workflow rule currently has pending actions in the workflow queue. To delete, please remove those pending actions.

The thing is that those pending actions were deleted a week ago, from both environments, the first time this came up. And I also deleted the workflows from my Eclipse project, deployed succesfully, and then re-added them to the project to make sure there was nothing in Eclipse that was the issue. Definitiely seems like the "Sending" Sandbox is "remembering" that there used to be pending actions.

Any suggestions on what I can do to clear this old information out?

Hi,

 

I am developing a Java application talking to Salesforce with the WebService API. I have generated my Java library from the Entreprise WSDL with wsc-20.jar.

I got my connection running and the user is now logged in without a problem. I request a Document and am now trying to get the Body in a String.

I cannot understand what to do with byte[] we get from object.getBody().

It says in the documentation:
"Required. Encoded file data. If specified, then do not specify a URL."
And then for type base64:
"Base 64-encoded binary data. Fields of this type are used for storing binary files in Attachment records, Document records, and Scontrol records. In these objects, the Body or Binary field contains the (base64 encoded) data, while the BodyLength field defines the length of the data in the Body or Binary field. In the Document object, you can specify a URL to the document instead of storing the document directly in the record."

So I understand that the data in the body of the document is encoded in base64. So I need to decode it.

I found this method provided by Salesforce:
com.sforce.ws.util.Base64.decode

I also found examples of:
org.apache.commons.codec.binary.Base64

I tried both ways and I still can't get my file's content right.

Here is my code:

 

public void queryRecords() {
		QueryResult qResult = null;
		  try {
		    String soqlQuery = "SELECT name, body, BodyLength, Type FROM Document LIMIT 10";
			qResult = connection.query(soqlQuery);
			boolean done = false;
			if (qResult.getSize() > 0) {
			  System.out.println("Logged-in user can see " + 
			      qResult.getRecords().length + 
			      " Document records."
			  );
			  while (! done) {
			    SObject[] records = qResult.getRecords();
			    for ( int i = 0; i < records.length; ++i ) {
			    	Document con = (Document) records[i];
				    String fName = con.getName();
				    int bodyLength = con.getBodyLength();
				    String type = con.getType();
				    System.out.println("Doc name " + (i + 1) + ": " + con.getName() + " - bodyLength: "+bodyLength+" - type: "+type);
				    
				    System.out.println("Doc body " + (i + 1) + ": " + con.getBody());
				    System.out.println("Doc body " + (i + 1) + ": " + con.getBody().toString()); 
				    System.out.println("Doc body sf" + (i + 1) + ": " + com.sforce.ws.util.Base64.decode(con.getBody()) );
				    System.out.println("Doc body sf 2" + (i + 1) + ": " + com.sforce.ws.util.Base64.decode(con.getBody()).toString() );
				    
				    String decodedResult = Base64.decodeBase64(con.getBody()).toString();
				    System.out.println("Doc body commons decode" + (i + 1) + ": " + org.apache.commons.codec.binary.Base64.decodeBase64(con.getBody()));
				    System.out.println("Doc body commons decode" + (i + 1) + ": " + decodedResult);
				    
				    String decodedResult2 = con.getBody().toString();
				    System.out.println("Doc body " + (i + 1) + ": " + decodedResult2);
				    
			    }
			    if (qResult.isDone()) {
			        done = true;
			    } else {
			        qResult = connection.queryMore(qResult.getQueryLocator());
			    }
			  }
			} else {
			  System.out.println("No records found.");
			}
			  System.out.println("\nQuery succesfully executed.");
		  } catch (ConnectionException ce) {
		    ce.printStackTrace();
		  }
	}

 

 

I would be really grateful if you could give me any advice.

Cheers,
Laurent

Hi,

 

I would like to know the Profile permission for a User to be able to Manage a Custom Settings.

Right now my User can click on Manage, then New but when he clicks on Save this message appears:

 

 

  Insufficient Privileges
You do not have the level of access necessary to perform the operation you requested. Please contact the owner of the record or your administrator if access is necessary. 

 

Cheers,

 

Laurent