- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-07-2018 01:26 AM
Hi All,
I am having issue where i want to throw alert to user in business rule. Currently my business rule is running on sys_attachment table. The condition is like below :
The code is like below which checks if the file size is greater than certain limit :
(function executeRule(current, previous /*null when async*/) {
var i = parseInt(current.size_bytes);
gs.addErrorMessage('i is' + i);
if(i > 10)
{
current.setAbortAction(true);
gs.log('-=--------------------------i is' + i);
gs.addInfoMessage("File Size is too large");
}
})(current, previous);
All other script work but none of the gs.addInfoMessage() functions are working. I can able to see the log message and action is getting aborted as per script just needed the alert message throw to user.
I have tired various solution provided in community and forum but none of them worked.
Can someone please help on this case
Regards,
Naresh
Solved! Go to Solution.
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-22-2018 05:31 AM
Just to update on this, I have achieved this by adding some code in UI page which helped me to restrict based on image size.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-07-2018 03:32 AM
Hi BeBold,
BRs is in Global scope.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-07-2018 02:31 AM
Hi Naresh
Use this in a business rule.. Tried and tested
var msg='haha';
gs.addErrorMessage('<script>var t=setTimeout(function(){var test = confirm("' + msg + '");if(!test){return false;}},500);</script>' + msg);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-07-2018 03:33 AM
Hi Anurag,
I have also tried this but didnt worked. btw i am on Kingston instance.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-07-2018 03:34 AM
HI,
I've never used a gs.addinfomessage after setAbortAction(true). I've not even previously considered if that is an issue, interesting. Just try this, should do the trick:
(function executeRule(current, previous /*null when async*/) {
var i = parseInt(current.size_bytes);
gs.addErrorMessage('i is' + i);
if(i > 10)
{
gs.log('-=--------------------------i is' + i);
gs.addInfoMessage("File Size is too large");
current.setAbortAction(true);
gs.setRedirect(current);
}
})(current, previous);
Regards
Paul
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-07-2018 03:50 AM
Hi Paul,
Somehow that did worked partly.. When i am trying to upload attachment in incident form the alert is coming to other tab on which same instance of servicenow is opened. This seems strange.
Also the upload process seems to be getting stuck in progress with progress bar keep running.
Thanks