The Zurich release has arrived! Interested in new features and functionalities? Click here for more

The following mandatory fields are not filled in:

sarosana
Kilo Contributor

Hi community,

I want to set focus on the mandatory field if it is not filled by the user after click on Save/Update button,

Please find the snapshot below,

find_real_file.png

Here I just want to focus the Resolution Code if it is not filled by the user.

Like that the focus should be set on the first mandatory field based on the error message.

How to do that?

Please help me.

Thanks,

AnnBel

14 REPLIES 14

adityaghosh
Tera Guru

in html / js its done like this



document.getElementById("mytext").focus();



so if theres a varible, you'' have to find its atcual ID eg.IO:6868 (by clicking on view source page


or inspect element F11)


and use it


document.getElementById("IO:0989078904645645").focus();


but this'll not work in Portal..


.focus() method is not build on SN, due to some very good reason..



so I would suggest avoid using it and use the pop-up message



Still, in SN you can use the in- build method showFieldMsg



you may try the below code too..



document.getElementById('sys_original.incident.number').focus();


Chandu Telu
Tera Guru
Tera Guru

HI Anna,



Please provide the more information on your requirement



you want to make a Resolution Code is mandatory


oharel
Kilo Sage

Hi Anna,


Or you can focus instead on the tab where the fields are. If the fields are in the first tab from the left, use in your UI action:


g_tabs2Sections.setActive(0);


If they are on the second tab, use


g_tabs2Sections.setActive(1);



etc.


harel


sarosana
Kilo Contributor

HI All,


harel ben-sheffer,chandu telu,Shiladitya Ghosh


Thanks for your response.



I just want to know the place where they have written these error messages & likewise the code to make the focus on the first mandatory field.