- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-21-2016 10:18 AM
We would like to provide some instructions, but only on a new record form. There is a use case to allow some users access to the regular form but in specific cases we want to make sure that appropriate record producers are used. We added an Annotation to the form containing instructions and links to those record producers. The annotation isn't appropriate when a record already exists.
Is there a simple way to remove the Annotation from the form if the record is not new?
I've seen proposed solutions where you try to hide it with CSS hacks but they leave a space where it would normally appear.
Is there a possibly better alternative solution?
Thanks,
Brad
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-21-2016 01:11 PM
The solution I found was to avoid using an Annotation altogether. Trying to hide it with the View Rules solution would require too much effort. Hiding it by manipulating the DOM was theoretically possible, but I couldn't make a Client Script to do that. Instead I removed my annotation and simply created an On Load client script that uses g_form.addInfoMessage(same annotation text) to the same effect.
function onLoad() { // Display instructions and links if the form is displaying an existing record. if(g_form.isNewRecord()){ g_form.addInfoMessage([html that mimics the desired annotation]'); } }
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-21-2016 12:10 PM
My view rule form doesn't have an Advanced link? We are still on Fuji if that matters?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-21-2016 10:24 AM
Write a on load client script.
if (g_form.isNewRecord())
{
document.getElementById("annot").parentNode.style.display="block";
}
else
{
document.getElementById("annot").parentNode.style.display="none";
}
Change the the id name(Bold text)
Thanks,
Mihir

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-21-2016 10:26 AM
Warning: DOM access is risky. It may not work across ServiceNow releases.
Client Script Best Practices - ServiceNow Wiki
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-21-2016 01:05 PM
I agreed w Chuck Tomasi that modifying the DOM isn't a good solution, but tried it anyway. I could not get it to work within the script. I was able to hide the Annotation by fiddling around in the browser console, so DOM manipulation is possible. This was helpful as it led me to find a simple solution that works which I'll post in response to my original question.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-21-2016 01:11 PM
The solution I found was to avoid using an Annotation altogether. Trying to hide it with the View Rules solution would require too much effort. Hiding it by manipulating the DOM was theoretically possible, but I couldn't make a Client Script to do that. Instead I removed my annotation and simply created an On Load client script that uses g_form.addInfoMessage(same annotation text) to the same effect.
function onLoad() { // Display instructions and links if the form is displaying an existing record. if(g_form.isNewRecord()){ g_form.addInfoMessage([html that mimics the desired annotation]'); } }