We've updated the ServiceNow Community Code of Conduct, adding guidelines around AI usage, professionalism, and content violations. Read more

How to get sys ID of the HR case record submitted via portal using client script?

Kushi
Tera Contributor

I need to fetch the sysID of the HR case for a record producer submitted using client script. Using this sysID i am checking if the attachment has to be added while submitting the form for which i am gliding the attachment table.

 

Kushi_0-1715323804577.png

 

1 ACCEPTED SOLUTION

Sruthi17
Mega Sage

Hi @Kushi ,

You can try this with the below script

 

function onSubmit() {
    if (g_form.getValue('has_post') == 'yes') {
        if (this.document.getElementsByClassName('get-attachment').length == 0) {
            alert("Attachment Mandatory. Please attach supporting documents");
            return false;
        }
    } else {
       return true;
    }
}

 

Please mark helpful or accept solution if it solves your issue, Thanks

View solution in original post

2 REPLIES 2

Sruthi17
Mega Sage

Hi @Kushi ,

You can try this with the below script

 

function onSubmit() {
    if (g_form.getValue('has_post') == 'yes') {
        if (this.document.getElementsByClassName('get-attachment').length == 0) {
            alert("Attachment Mandatory. Please attach supporting documents");
            return false;
        }
    } else {
       return true;
    }
}

 

Please mark helpful or accept solution if it solves your issue, Thanks

Kushi
Tera Contributor

Thankyou. This script works 🙂