Pedro Grilo1
Mega Sage

Hi!

 

Can you add a screenshot of the entire UI Action?

 

Best regards,

Pedro

Added the screeshot of the UI action.

Not applicable

Hi

 

The code is incorrect. action.setRedirect is supposed to be inside the server script instead of client function.

 

However if you only need to update the field then no need to make the UI action to be run as Client first.

1. Uncheck the Client checkbox

2. Write below code to update the description:

current.description  = "Any value"
current.update();
action.setRedirectURL(current.getLink());

 

For more information on how client and server side code works in UI action, please follow:

https://servicenowguru.com/system-ui/ui-actions-system-ui/client-server-code-ui-action

 

Please mark this answer correct/helpful if it helps.

 

Thanks

Deepak

Hi @Deepak Negi ,

TRhis will work but If made any change to anyother fields those will also get updated. I want to update the description field only.

Voona Rohila
Tera Patron

Hi , Try this in your UI Action code

function saveDesc() {
    var desc = g_form.getValue('description');
    g_form.setValue('description', desc);
    gsftSubmit(null, g_form.getFormElement(), 'save_dec'); 
}
if(typeof window == 'undefined')
runBusRuleCode();

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