1
votes

I have encoded string data to base64 format and setted the output to custom field which is type is long text. In the user interface of the record I could see whole output of encoded value. But while try to get the output value with using rec.getText({fieldId:'customfieldname'}) somehow it breaks the value and doesn't return whole value. Is there any limit size of custom field value?

UserEvent script to get the custom field value:

function beforeSubmit(scriptContext) {

  try {
      var invrecord = scriptContext.newRecord;
      var encodedata = invrecord.getText({fieldId: 'customfield'});

      log.debug({title:'Custom field value',
                details: encodedata});
      return true;
      }
  catch (e) {  
      log.error({
             title: e.name,
             details: e.message
               });
       return false;
     }}
   return {
   beforeSubmit: beforeSubmit, };});

To encode field value I have used code below:

        function encodeBase64Binary(strdata) {
        try{
            var base64EncodedString = encode.convert({
                string: strdata,
                inputEncoding: encode.Encoding.UTF_8,
                outputEncoding: encode.Encoding.BASE_64
            });
            return base64EncodedString;
        }
        catch (e) {
               log.error({
                   title: e.name,
                   details: e.message)} 
                  }
1
Long text holds 1,000,000 characters when created through the UI, 100,000 when created through SuiteScript. Have you tried getValue instead of getText?ehcanadian
You could also set it to HIDDEN + INLINEHTML since I doubt seeing base64 data is requiredxpeldev
@ehcanadian yeah I have tried getValue. Both returns same result.niso
@niso How do you know the script is not getting the whole value? If you're relying on log.debug you may not see it all because logging truncates the value to 3,999 chars.ehcanadian
@ehcanadian yeah exactly it returns whole data but in logs it doesn't show all of them. In this case should I answer my post or how could we close it?niso

1 Answers

3
votes

The value of the field contains the value you're looking for, however, log.debug truncates the value to 3,999 characters. That's why you're not seeing the complete value.