3 Things I Learned in January 2021

Copy text to clipboard

Recently, I had to create a Context Menu to copy some elements from a list to the clipboard.
Servicenow does that OOTB in a few places, so no need to reinvent the wheel!
Let’s have a look at the UI Action “Copy sys_id”:
function runContextAction() {
Pretty simple, right?
You just need to use the function “copyToClipboard” and pass the text you want to copy as a parameter.
If you are interested in having a look at the function definition, you can find the code in your instance:

Insert Widget in GlideModal

Have you ever tried to put a Portal Widget inside an iframe inside an UI Page inside a Pop Up… I swear I had no choice!

HTML Work notes/Comments in Agent Workspace

Having HTML fields for Work notes and Comments for Tasks.
I’ve seen that requirement a few times and I haven’t found the perfect solution yet.
But in the Agent Workspace, you just need to set a System Property:
Controls whether journal entries in workspace are displayed as html fields or string fields (true = html, false = string)