function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ 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.

Code:
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; 
};

 

SteveBowerSteveBower
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:

http://forums.sforce.com/sforce/board/message?board.id=general_development&message.id=6336

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