- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-08-2021 01:31 AM
Hi!
Can you add a screenshot of the entire UI Action?
Best regards,
Pedro
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-08-2021 01:35 AM
Added the screeshot of the UI action.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-08-2021 01:39 AM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-08-2021 01:46 AM
Hi
TRhis will work but If made any change to anyother fields those will also get updated. I want to update the description field only.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-08-2021 01:45 AM
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);
}