Skip to content

Instantly share code, notes, and snippets.

@thisnameissoclever
Created May 31, 2022 15:46
Show Gist options
  • Save thisnameissoclever/fda8224b209a39ddae1de04a42b22841 to your computer and use it in GitHub Desktop.
Save thisnameissoclever/fda8224b209a39ddae1de04a42b22841 to your computer and use it in GitHub Desktop.
Expanding infomessage with functional components in ServiceNow
var message = '';
message += 'This is an expanding info message. It can even run code! Click "Show more" to see!';
message += '<div>';
message += '<p><a href="#" onclick="javascript: jQuery(this.parentNode).next().toggle(200);">Show more</a></p>';
message += '<div style="display: none;">';
message += '<ul style="list-style: none">';
message += '<li>This is the expanded info in the message.</li>';
message += '<li>You can include any details you like here, including info retreived from a script like the sys_id of the current record: ' + g_form.getUniqueValue() + '</li>';
message += '</ul>';
message += '<p>You can even run a script when an element is clicked <a href="#" onclick="javascript: alert(\'See? ^_^\');">like this</a>. You just have to escape your code in the HTML.</p>';
message += '</div>';
message += '</div>';
g_form.addInfoMessage(message);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment