worknotes ignoring the dictionary Max length

scwillson
Mega Guru

By default, work_notes has a max length of 4000, but it doesn't work.

I've tried making it work by getting control with g_form.getControl, but that doesn't work either.

var w = g_form.getControl('work_notes');

if (w)

  w.setAttribute("maxlength", 1000);

I've tried it with both an onLoad, and onChange. Nothing is able to restrict it.

Initially, I thought it might have been related to the additional container that work_notes and additional_comments are grouped in (starting with Geneva), but I tested it in Fuji as well, and it is   a problem across the board.

The reason I need this is because we built an custom table that extends task (hence the work_notes), and they send information from this table to a vendor. The vendor only accepts 1000 characters.

Any suggestions?

1 ACCEPTED SOLUTION

Pradeep Sharma
ServiceNow Employee
ServiceNow Employee

Hi Simon,



You can write a onSubmit Client script for validation. Here you go.


function onSubmit()


{



  var wnote = g_form.getValue('work_notes');


  if(wnote.length > 1000)


  {


  alert('YOUR MESSAGE')


  return false;


  }


}



View solution in original post

7 REPLIES 7

Hi Sourabh,



Just so you are aware DOM manipulation (document.getElementByID is included) is not supported by ServiceNow and may cause issues between releases.


sourabhd87
Tera Contributor

Thanks Chuck,



But there are cases where we have used such manipulation.


eg. When one want to add a number of desktop requests in one single request. Every time the desktop number may change.


We have used it as a last option.



Kind regards,


Sourabh


scwillson
Mega Guru

Thanks all for the quick feedback



I think I'll just go with the onSubmit to check the length.