move cursor to a section

davejr
Giga Contributor

I have successfully used g_tabs2Sections.setActive(X);   to highlight/activate a section in a form from (1) an onChange client script and (2) from a UI action button,

but the customer wants the users cursor to be placed in that section also.   Can we do that ?   Thank you.

1 ACCEPTED SOLUTION

Brad Tilton
ServiceNow Employee
ServiceNow Employee

I think you would just have to set the focus to be the first field in the section. Unfortunately, I'm not aware of a great way to automatically get the first field in the section so you'd have to hardcode the field name. Something like this:



g_form.getControl('fieldname').focus();


View solution in original post

5 REPLIES 5

HI Brad,

 

In reopen UI action, I am using following 3 lines.But g_form.getControl('comments').focus();  is not  focusing additional comments field . Is any way to do this ?

 

g_form.setMandatory('comments', true);
g_form.addErrorMessage('Please enter the comments ');
g_form.getControl('comments').focus();