How to add a message after adding an attachment
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-11-2014 11:16 AM
Hi,
Im looking for a way to add some sort of message after a user uses the attachment GUI to add an attachment to an approval ticket.
I have a business rule that does something with the attachment when it's added. I want to inform the user what happened with it. Using gs.addInfoMessage in the business rule doesn't work since the user isn't loading a new screen.
One thought that I had was to add a field to sysapproval_approver, hide it on the form via ui policy, increment that field in the business rule and then use an onChange client script to key in on that field and post the message. That seems like a lot of pieces for something that might not be as complicated.
Any ideas?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-24-2015 09:30 AM
Not the best and clean but easy way to achieve this is to use something like below in Business Rule on sys_attachment according to your own conditions.
var msg = "<Your message here>"
gs.addInfoMessage('<script>var t=setTimeout(function(){alert("' + msg + '")},500);</script>' + msg);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-24-2015 09:58 AM
Hi captain,
don't know if this will work to be honest as it's just a quick idea...What if you create an on insert Business Rule which runs on the sys_attachment table & will throw a message via gs.addInfoMessage()?
The condition can be fitted to your needs.
Kind regards,
Stijn
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-25-2015 02:09 AM
Hi Stijn,
That doesn't work unfortunately. Tried it before coming to this.
Thanks,
Ravi
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-25-2015 02:40 AM
Hi Ravi,
I've found a solution for you. Go to the UI Page attachment -> in the Client Script of the page; search for the function refreshAttachments. Than place the line of code g_form.addInforMessage() (as pictured below) after the line of code addAttachmentNameToForm.
...
addAttachmentNameToForm(id, fileName, anchor.title, imgSrc, allowRename, showView, showPopup);
g_form.addInfoMessage("Hello World");
if (g_accessibility)
...
This works fine for me. However; do note your UI Page won't be updated anymore automatically (in case of fixes or improvements by ServiceNow themselves) if you upgrade your instance as you've changed the OOB code.
Kind regards,
Stijn