Preventing form submission when there is no attachment

lhieanne
Tera Contributor
 
14 REPLIES 14

Hi @lhieanne ,

 

Use getXMLWait() instead of getXMLAnswer.

 

-------------------------------------------------------------------------

If you found my response helpful, please consider selecting "Accept as Solution" and marking it as "Helpful." This not only supports me but also benefits the community.


Regards
Runjay Patel - ServiceNow Solution Architect
YouTube: https://www.youtube.com/@RunjayP
LinkedIn: https://www.linkedin.com/in/runjay

-------------------------------------------------------------------------

 

but getxml wait is not supported in portal

Hi @lhieanne ,

 

use below code, no need of calling script include.

function onSubmit() {
    // Use the g_attachment API to check for attachments

    if (this.document.getElementsByClassName('get-attachment').length == 0) {
        alert("You must attach Template Document");
        return false;


    }
    return true; // Allow form submission if attachments exist
}

 

-------------------------------------------------------------------------

If you found my response helpful, please consider selecting "Accept as Solution" and marking it as "Helpful." This not only supports me but also benefits the community.


Regards
Runjay Patel - ServiceNow Solution Architect
YouTube: https://www.youtube.com/@RunjayP
LinkedIn: https://www.linkedin.com/in/runjay

-------------------------------------------------------------------------

Hi @jaycoover ,

Did you tried this? its working for me.

dom manipulation is BPE