Script for fetching limited no: of characters from incident description

Hi Experts,

 

My requirement is to create a script that I can use in html templates. Which will allow only 1400 characters from the description field of an incident.

Following is the script I have tried. But When I use this in the html template (Expression) I could see the preview as null.

 

var max = $RECORD.action.length();

var actioncopy='';

var copy='';

var total=0;

var count=0;

for ( var i=0; i< max; i )

    if ( $RECORD.action[i] != "")

    {

     copy= $RECORD.action[i];

     var max2=$RECORD.copy.length();   

If( total max2 >1400)  

break;

else

total=total max2;

actioncopy=actioncopy $RECORD.action[i];

}

}

actioncopy = actioncopy.replace(/null/g,"<br/>");  

 

action refers to the description field.

Please anyone suggest me a solution.

 

Thanks & Regards,

Sandhu Mol