how to set the value of the Choice type field based on the function for form UI button?

zbackm
Kilo Contributor

What i wanted to do is when i click the accept button the choice type field from new to in progress

 

example:

 

the choice selected after i create new record is State=New when i click the Accept button the state will change to in progress( State=In Progress)

 

this is my code

function ProgressIncident(){
//Set the 'Incident state' and 'State' values to 'In Progress', and display mandatory fields
g_form.setValue('incident_state', 2); 
g_form.setValue('state', 2);
g_form.setValue('inprogress_by', g_user.userID);

gsftSubmit(null, g_form.getFormElement(), 'inprogress_incident'); //MUST call the 'Action name' set in this UI Action
}

//Code that runs without 'onclick'
//Ensure call to server-side function with no browser errors
if (typeof window == 'undefined')
serverAccept();

function serverAccept(){
current.incident_state = IncidentState.InProgress;
current.update();
current.resolved_by = gs.getUserID();
}

but the problem is when i click the button.. it will reload the form and automatically back to the list like a submit button.. when you click the submit button it will automatically go to the list ..

find_real_file.png

1 REPLY 1

Simon Christens
Kilo Sage

but the problem is when i click the button.. it will reload the form and automatically back to the list like a submit button.. when you click the submit button it will automatically go to the list ..

 

In your server part of the script after current.update() you can use:

action.setRedirectURL(current)

This will redirect the user back to the incient form instead of the list