Call a script Include from UI Action

hadron_collider
Tera Contributor

Hello!

 

 

Im working on a functionality that will allow to change the status of a record when a button is clicked.

 

I have an UI Action (client) so that when the button is clicked 'reason for reject' shows up and is set to mandatory:

kata90_0-1704814723056.png

 

 

I want the approver to be obliged to provide 'reject reason' to be able to change the status to 'rejected'.

 

Here is my UI action:

 

kata90_1-1704814816919.png

 

is it possible to call Script Include that will handle the logic of the record update? (changing the field value to 'rejected' and adding the 'reject reason').

 

 

Thank you in advance!

 

1 ACCEPTED SOLUTION

I corrected this in my reply above, see this

if( g_form.getValue('u_activity')== ''){   // this if was wrong
return false; //Abort submission 
}
-Anurag

View solution in original post

15 REPLIES 15

Anurag Tripathi
Mega Patron
Mega Patron

Hi,

You can use a ui action that can run client and  server code both, like below

function runClientCode(){
if( == false){
return false; //Abort submission
}
//Call the UI Action and skip the 'onclick' function
gsftSubmit(null, g_form.getFormElement(), ''); //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')
runBusRuleCode();

//Server-side function
function runBusRuleCode(){
current. = ;
current.update();
gs.addInfoMessage('You did it!');
action.setRedirectURL(current);
}
-Anurag

Please correct me if i am wrong: I have to create another server side UI action that will handle the record update logic and then in the client UI action I have to add the name of it:

kata90_0-1704815537945.png

No this is the same ui action that you have, the client side one, you can just modify it to run server side script also

 

function onClick(){
if( == false){
return false; //Abort submission
}
//Do the client side things here, making field mandatory and all that

gsftSubmit(null, g_form.getFormElement(), '<add the action name of the this client siode ui ction here>'); 
}

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

//Server-side function
function runServerCode(){

//Do the server side things here

action.setRedirectURL(current);
}

 

-Anurag

So what the field "Action Name" is for?