g_form method focus() not working on Additional Comments field

Milan13
Giga Expert

Hello,

I have an onChange() client script on "state" field - once this field is changed I need the cursor to be focused on "Additional comments" field however this does not work:

g_form.getElement('incident.comments').focus(); 

This method works for other fields however comments - label: Additional Comments field is according to dictionary located in task table, there is a dictionary override for this field as per below but not sure how this works...

Any idea how this works?

Many thanks,

Milan

find_real_file.png

 

1 ACCEPTED SOLUTION

Omkar Mone
Mega Sage

Hi 

The solution that Raf provided, keeping the same, can you confirm if the isolate script checkbox on your client script is checked or unchecked? If it is checked, please uncheck it and try once.

 

Regards,

Omkar Mone.

www.dxsherpa.com

View solution in original post

9 REPLIES 9

Allen Andreas
Administrator
Administrator

Hi,

Can you try:

var refocus = document.getElementById('incident.comments');
refocus.focus();

Please mark reply as Helpful/Correct, if applicable. Thanks!


Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!

Hi Allen,

 

unfortunately it does not work as I am getting this message once changing state to "on hold":

 

onChange script error: TypeError: Cannot read property 'getElementById' of null function () { [native code] }

 

MAny thanks,

Milan

Raf1
Tera Guru

Hi Milan,

Saw this on a previous post, give it a try:

var comments = gel("activity-stream-textarea");


if (comments){
 comments.focus();
 }


or/and


comments = gel("activity-stream-comments-textarea");
 if (comments) {
 comments.focus();
 }

 

Regards,

Raf

It does not work (none of thesse) unfortunately.

 

Thanks a anyway.

Milan