We've updated the ServiceNow Community Code of Conduct, adding guidelines around AI usage, professionalism, and content violations. Read more

set field focus in Service portal

salu
Mega Guru

Hello Friends,

Can some help me to find out a solution for this.

I need to set focus on a field in Service portal on change of a variable.

Thanks

Saranya

1 ACCEPTED SOLUTION
3 REPLIES 3

salu
Mega Guru

Adam Syed1
Kilo Contributor

To focus on a field in record producer on portal side copy and paste the below code in your onload client script and replace the "011a705e1355d348eb633598d144b023" with the sys_id of that field.

 

setTimeout("var refocus = document.getElementById('sp_formfield_IO:011a705e1355d348eb633598d144b023');refocus.focus();",0);

 

 

Thanks,

Adam Syed

Hi Adam,

I just used this in a Record Producer catalog client script, onChange, which checks for a valid number (doesn't allow text) and the re-focus works really well, thanks for posting.

 

Cheers

Carl.