Email Properties Page - How to Modify the Save Button?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-10-2024 11:43 AM
Hello. My organization is looking for the following behavior...
When the user checks the "Email sending enabled" checkbox on the "Email Properties" page, and then clicks on the "Save" button, we want some sort of a Popup Dialog which says something like "You are turning ON email sending from this instance. Automatically delete all pending messages in the Outbox? Yes or No"?
Where and How can something like this be accomplished? Thank you?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-10-2024 11:50 AM
Hi @G24
I doubt , we can make any changes, as it is not a table, it is like a UI page, so you need to check UI page and if get success, we can make change. I would like to hear from experts on this.
If my response proves useful, please indicate its helpfulness by selecting " Accept as Solution" and " Helpful." This action benefits both the community and me.
Regards
Dr. Atul G. - Learn N Grow Together
ServiceNow Techno - Functional Trainer
LinkedIn: https://www.linkedin.com/in/dratulgrover
YouTube: https://www.youtube.com/@LearnNGrowTogetherwithAtulG
Topmate: https://topmate.io/atul_grover_lng [ Connect for 1-1 Session]
****************************************************************************************************************
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-10-2024 11:50 AM
Hi @G24
https://support.servicenow.com/kb?id=kb_article_view&sysparm_article=KB0716365
This might helpful.
If my response proves useful, please indicate its helpfulness by selecting " Accept as Solution" and " Helpful." This action benefits both the community and me.
Regards
Dr. Atul G. - Learn N Grow Together
ServiceNow Techno - Functional Trainer
LinkedIn: https://www.linkedin.com/in/dratulgrover
YouTube: https://www.youtube.com/@LearnNGrowTogetherwithAtulG
Topmate: https://topmate.io/atul_grover_lng [ Connect for 1-1 Session]
****************************************************************************************************************

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-11-2024 11:31 AM
I do not have the answer to the question, but I found a workaround. I ended up using a regular Business Rule to abort the setting change if there are too many emails in the Outbox...
(function executeRule(current, previous /*null when async*/ ) {
//Gather system properties.
var maxMessagesInOutbox = gs.getProperty("glide.email.smtp.maxMessagesInOutbox") || 10;
//Create the hyperlinks that we will display to the user.
var outboxLink = "<a href='[XXX]/now/nav/ui/classic/params/target/sys_email_list.do%3Fsysparm_query%3Dmailbox%3Doutbox' target='_blank'>Outbox</a>";
var scriptLink = "<a href='[XXX]/nav_to.do?uri=sysauto_script.do?sys_id=5ff8726793588ed497a3f23e1dba102e' target='_blank'>Delete Script</a>";
var sysPropertyLink = "<a href='[XXX]/now/nav/ui/classic/params/target/sys_properties.do%3Fsys_id%3D5fed30a4eb32c6107ffcff3ccad0cd78' target='_blank'>Here</a>";
//Make the hyperlinks instance-independent.
outboxLink = outboxLink.replace("[XXX]", gs.getProperty('glide.servlet.uri'));
scriptLink = scriptLink.replace("[XXX]", gs.getProperty('glide.servlet.uri'));
sysPropertyLink = sysPropertyLink.replace("[XXX]", gs.getProperty('glide.servlet.uri'));
//Check the number of messages in the sys_email table Outbox.
var myGR = new GlideRecord("sys_email");
myGR.addEncodedQuery("mailbox=outbox");
myGR.query();
var rowCount = myGR.getRowCount();
//If we have more messages there than are allowed...
if (rowCount > maxMessagesInOutbox) {
//Build message for the end user.
var sMessage =
"Cannot enable system property 'glide.email.smtp.active'. There are too many ("
+ rowCount + ") messages in the Outbox. Only " + maxMessagesInOutbox + " messages are allowed "
+ "as defined " + sysPropertyLink + ". "
+ "First, use the " + scriptLink + " to purge all messages from the Outbox. "
+ "Or manually remove messages from the " + outboxLink + ". Then try again.";
//Display message at top of form.
gs.addErrorMessage(gs.getMessage(sMessage));
//Abort the database operation.
current.setAbortAction(true);
}
})(current, previous);
And here is the sysauto_script to do the actual Purge operation:
//Script to purge messages from table sys_email where the mailbox == outbox.
var myGR= new GlideRecord("sys_email");
var myEncodedQuery = "mailbox=outbox";
myGR.addEncodedQuery(myEncodedQuery);
gs.addInfoMessage("START Delete Operation."); gs.info("START Delete Operation.");
myGR.query();
myGR.deleteMultiple();
gs.addInfoMessage("END Delete Operation."); gs.info("END Delete Operation.");