+ Start a Discussion
Ron HessRon Hess 

get body of large text fields

I had to write this today, may be usefull to others
I used this to fetch the body of large text fields which contain data greater than 4096 bytes.

Sforce.Dynabean.prototype.getLargeText = function(propName) { 
 // like get(), but will unpack document body elements which are greater than 4096...
 var body=''; 
 try { 
  var tmp = this.getItem(propName).value; // still could return a null, watch for that when calling
  if ( Sforce.Util.dltypeof(tmp) == "domelement" ) {  // see what type of object tmp is...
   for (var i=0; i < tmp.childNodes.length; i++) { 
    body += tmp.childNodes[i].textContent; 
  } else { // normal string if body is < 4096 bytes 
   body = tmp; 
 } catch (e) { throw(e); }
 return body; 


I went through this same stuff several months ago and discovered the same solution you've found.

However, I think I found a cleaner fix, something that perhaps should be incorporated into the sforceclient.js file during it's next update cycle.

It's a small change to the ParseVal function which preserves the .get() functionality, as well as re-balancing the Base 64 stuff which is unbalanced in the current API.  (in the sense that you have to decode it, but not encode it.)

Please refer to thread:


For the code fix.  (obviously, if you didn't want ParseVal to undo the Base64 stuff, you can just treat it as a 'textarea' object.)

Thanks, Steve.

Any plans for a Beta 3.4 anytime soon?  There are a number of code fixes outstanding.  :-)

Ron HessRon Hess
thanks, i like your solution