petercawdron
Kilo Guru

This is a nice little script that brings an out-of-sight field on an unfocused tab to the forefront when the user takes an action.

As an example, a user is working on a change task and hits Cancel Task

find_real_file.png

But we want the user to enter closure information when cancelling the task, so we want the Closure Information tab to get the focus like this...

find_real_file.png

Here's the UI Action that controls this behavior

function moveToClosed() {
	if(g_form.getValue('close_notes')==''){
		g_tabs2Sections.setActive(1);//sets the second tab to active (the first tab is 0)
		g_form.setMandatory('close_notes',true);
		g_form.addErrorMessage("You must provide close notes to cancel this task");

	}else{
		g_form.setValue('state', 4);
		gsftSubmit(null, g_form.getFormElement(), "change_task_to_cancelled");
	}
}

if (typeof window == 'undefined')
   setRedirect();

function setRedirect() {
    current.update();
}

Have fun!

 

Comments
James Fricker
Tera Guru

Instead of this...

g_tabs2Sections.setActive(1);

I think this is more readable...

g_form.activateTab(g_form.getTabNameForField('close_notes'));

plus, it still works if the close_notes field gets moved to a different tab.

Version history
Last update:
‎11-24-2019 05:39 PM
Updated by: