UI Action not executing both client and server side script at same time

BharathKumar00
Tera Contributor
Hi,
I am trying to make a field mandatory using a client side function and setting another field to current date in server side function in a UI Action named review complete. When I click on the UI action link, the client side script is working and making the review notes field as mandatory but the client side script is not working. 
Server side script is only working when I click on the review complete UI action link twice i.e
--> On the first click, the alert is displayed and it is making review notes mandatory and I'm populating something.
--> On second click it is again giving the alert and now as I have populated something, the form is reloading and the          review date field is also being set to current date.
 
I need both of them to execute on the first click of UI action link. How to achieve this? Following is the script I have written in UI action
 
function makeMandatory(){
alert("client");
if(g_form.getValue('review_notes')== ''){
g_form.setMandatory('review_notes',true);
return false;
}

gsftSubmit(null, g_form.getFormElement(), 'review_complete');
}
callserverside();

function callserverside(){
    gs.addInfoMessage('Inside server');
    var d = GlideDateTime().getDate();
    current.review_date = d;
action.setRedirectURL(current);
}
2 REPLIES 2

Elijah Aromola
Mega Sage

You aren't going to be able to make the server script run after the first click unless that field has a value. When it runs the first time and sets review_notes to mandatory it prevents the form from submitting which doesn't execute the server code.

Hugo Gomes
Kilo Guru

Since you have a "return false" statement, it won't run the server side on the first click.