The CreatorCon Call for Content is officially open! Get started here.

Restrict additional comments field to accept only 4000 characters

Pandu3
Tera Contributor

Hi Team,

 

The requirement is to restrict the additional comments(Journal Input - field type) field to accept only 4000 characters on case record. Can anyone please help me how to achieve this requirement. Thanks in advance. I have written onChange client script on case table,

 

Script:  //testing purpose I'm trying to restrict 4 characters only

function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
}

var v_comments = g_form.getValue('comments');
var count = v_comments.length;
if (count > 5) {
alert("No.of characters " + count);
g_form.setValue('comments', v_comments.substring(0, 4));
}

}

 

Pandu3_0-1697806573024.png

 

still it is allowing to enter 5th character but the requirement is to stop allowing the 5th character.

 

Thanks! 

11 REPLIES 11

HI @Jaspal Singh ,

1)After entering 5th character , If I click on post option the comments are posting - need to restrict this

2) but if I enter 6th character then 5th & 6th characters are deleting and showing 4 characters only in target field.

 

Thanks!

In that case, you need a Before Insert BR on the sys_journal_field table.

Hi @Jaspal Singh,

Can you please help me on that. 

 

Thanks! 

JaspalSingh_0-1697819173998.png

 

(function executeRule(current, previous /*null when async*/ ) {

    var v_comments = current.comments;
    var count = v_comments.length;
    if (count > 5) {
        gs.addErrorMessage("No.of characters " + count);
        current.comments=v_comments.substring(0, 4);
    }

})(current, previous);

Hi @Jaspal Singh ,

no luck, it's not working.

 

Thanks!