The Now Platform® Washington DC release is live. Watch now!

Help
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Check for Attachments on Service Portal

mattrom1
Giga Expert

We have a onsubmit script for CMS that worked fine but this is not working on Service Portal.

function onSubmit() {

    //Type appropriate comment here, and begin script below

      var sys_id=gel('sysparm_item_guid').value;

    var gr = new GlideRecord("sys_attachment");

    gr.addQuery("table_name","sc_cart_item");

    gr.addQuery("table_sys_id",sys_id);

    gr.query();

    if (!gr.next()) {

              alert("Please attach the 'Desktop Software Security Review' filled out form before submitting this request");

          return false;

      }

}

Am i missing something that can cause it not to work on Service Portal

5 REPLIES 5

Bryan Tay3
Kilo Guru

hi Matt,



i believe this is what you are looking for.


Require attachment for catalog item in Service Portal



Hope this helps.


shloke04
Giga Sage

Hi,



You can review the below two blogs:



Service Portal: Require attachments — ServiceNow Elite


Require Attachments - ServicePortal.io



Hope this helps.Mark the answer as correct/helpful based on impact.



Regards,


Shloke


Hope this helps. Please mark the answer as correct/helpful based on impact.

Regards,
Shloke

Sontel
Tera Contributor

Anyone who's wondering why this code is not working in current time then let me tell you that there is a new option brought by SN from London release called Isolate script. This option is brought by SN to discourage use of DOM in SN scripting.

For all existing configurations before London (both OOB & custom), Service Now has set the Isolate script to False so it wont impact any of your existing scripts. For all new configurations that were introduced as part of London(or future releases), the Isolate script is set to True. 
 
So if it is a new script then please set the Isolate script to False and then try this code. By default Isolate script option is not over the form so you have to personalize the form to see that checkbox.

With Madrid, an out-of-the-box checkbox has been introduced to make Attachments mandatory / hidden on the Service Portal.

Check out an article I wrote about this:
Service Portal Catalog Items: Hide Attachment / Mandatory Attachment [Madrid]

Kind regards,
Mark

---

LinkedIn

 

Kind regards,

 

Mark Roethof

Freelance ServiceNow Consultant

9x ServiceNow Community/Developer MVP

---

 

350+ Articles, Blogs, Videos, Podcasts, Share projects - Experiences from the field

LinkedIn