I've been a bit busy lately but wanted to throw out a small post on a really helpful method I came across in my PDI when I needed to create a UI Action that created a record and redirected to the newly created record in both the Platform/Classic UI and the Workspace UI.
Most of us are used to using action.setRedirectURL in our UI Actions, because we've been coding them for the Platform UI for ages. This method sets the next page the user will see once the UI Action operation has completed, and it can contain either a URL or GlideRecord.
Note: action.setRedirectURL isn't supported in the Service Portal when using the Form widget.
I've found that action.setRedirectURL does not work in the Workspace UI but there are times where you want to create a UI Action that runs server side to insert/update a record and then redirect to it, instead of the current record. While setRedirectURL does give us the redirecting to a URL option, from my experience record redirections are going to be used most of the time in the Workspace UI and there are component options to create buttons for opening URLs.
There is documentation on openGlideRecord (yay!) and it seems like it would be a better replacement for setRedirectURL in cases when you need to open a record, rather than redirecting to some other page type in both the Platform and Workspace UIs, especially if you're looking to implement Workspace, using it now would prevent refactoring tons of UI Actions in the future using setRedirectURL. Also, openGlideRecord does work in both scoped and global applications.
Here's a small snippet of how the UI Action server script would look, I'm going to mimic creating an Incident from a Case, even though there's an OOTB UI Action for that. I'm not going to create this as a Client UI Action or fill anything into the Workspace Client Script field, but I am going to click 'Workspace Form Button' so that it shows on the Workspace UI as well. This what I put in the 'Script' field:
var incGr = new GlideRecord('incident'); incGr.newRecord(); incGr.setValue('caller_id', current.getValue('contact')); incGr.setValue('short_description', current.short_description); incGr.insert(); action.openGlideRecord(incGr);
Here's a quick video of me clicking the UI Action in both the Platform UI and the Workspace UI.