Manipulating the "Post" button
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-03-2020 07:42 PM
Hi Community ,
Is there anybody who has tackled a requirement of enabling a confirmation pop-up once the Post Button is clicked with/without DOM manipulations ?
I am able to get to a point where on click of the Post button , the confirmation box appears.
However, an OK or CANCEL still inserts a record into the additional comments.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-03-2020 08:06 PM
Hi,
Can you share the script which is allowing you to open confirm box when post button is clicked
Also what code is written when CANCEL is clicked?
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-03-2020 08:36 PM
Hi Ankur,
Here is the outlined code... Not complete in entirety though
function onLoad() {
window.setTimeout(addPostListener,2000);
}
function addPostListener(){
var PostButton = document.getElementsByClassName('activity-submit')[0];
PostButton.addEventListener("click", myFunction) ;
function myFunction() {
if (confirm('You have entered Additional comments. Are you sure you wanted to do this?')){
//return true ;
}else
{
//alert("Not Confirmed");
//return false;
}
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-03-2020 10:21 PM
Hi,
can you try updating code as below and test once
function onLoad() {
window.setTimeout(addPostListener,2000);
}
function addPostListener(){
var PostButton = document.getElementsByClassName('activity-submit')[0];
PostButton.addEventListener("click", myFunction) ;
function myFunction() {
var retVal = confirm("You have entered Additional comments. Are you sure you wanted to do this?");
if( retVal == true ) {
// OK clicked
}
else{
// CANCEL clicked
return false;
}
}
}
Mark ✅ Correct if this solves your issue and also mark 👍 Helpful if you find my response worthy based on the impact.
Thanks
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-09-2020 08:43 PM
hi Ankur - Unfortunately declaring a variable and then checking for it , does not work either.