How to make attachments mandatory on variable condition IN Employee Center Pro

dwilborn
Tera Contributor

Hi All,

I have a requirement to make attachment mandatory if certain conditions are met on a catalog item.  We're using ESC Pro and this catalog item would be on the ITSM tables.  I've read lots of the articles on making this happen in Service Portal... but none of those methods appear to work in ESC?  Perhaps I'm missing something, but thought I'd ask the ESC community if anyone else has experience and found a solution.

 

Thanks!
Daniel

5 REPLIES 5

Mark Roethof
Tera Patron
Tera Patron

Hi there,

 

You do mention you tried several options. Can you share anything?

Basically Employee Center (Pro) is just a Service Portal, so same tech as the previous default Service Portal (which confusing enough was names the same...  Service Portal).

 

Kind regards,
Mark

 

Kind regards,

 

Mark Roethof

Independent ServiceNow Consultant

10x ServiceNow MVP

---

 

~444 Articles, Blogs, Videos, Podcasts, Share projects - Experiences from the field

LinkedIn

Hi Mark,

Appreciate the reply.  Everything I was doing involved a client script, a ui policy, or both.  Most of the community posts I referrenced for code were fairly old or seemed to reference those older posts.  Best as I can tell... what seems to have been the fairly widely used approaches of counting attachments, checking element 'get-attachment' length, or anything else I came across doesn't seem to work on San Diego.  A couple reference topics I tried to duplicate with appropriate changes to variable values and field names:

on submit make attachment mandatory in catalog cli... - Page 2 - ServiceNow Community

 

SERVICE PORTAL: Make Attachments Mandatory on Serv... - ServiceNow Community

It's also highly possible I bunged something up when trying to apply the code to my environment... though even as a JS novice I feel like this shouldn't have been terribly difficult.  I ended up using an attachment variable type (this doesn't show up as an option in catalog builder) and UI policy to require the attachment in line on a given condition.  This seems like a much better solution long term as I don't have to maintain any code and the result, while not exactly the behavior I'd like to see (attachment is a variable instead of attached to the record header / banner instead of field message)... it certainly gets the job done.

Daniel   

Daniel,
I'm running into the same issues with the documentation (broken links and the ones that work are all linked-loops around the same 'old' solution posts).  Also hit the same limits in the Catalog Builder (you can condition any other variables through behavior - *except* attachments).

Your comment:  " I ended up using an attachment variable type (this doesn't show up as an option in catalog builder) and UI policy to require the attachment in line on a given condition. " 


This is exactly what I'm trying to do.
For context, I'm also in the ESC, although my item is a Record Producer (not a standard Cat Item), as I need to generate a Case.
Can you provide any details on how and where you configured this?

Our default items have the attachment enabled and visible, but not mandatory.  I'm assuming it's necessary to hide that variable so the submitter is attaching via the variable?

Tim

Susan Britt
Mega Sage
Mega Sage

Something similar to this should work as an onSubmit Catalog Client Script.

 

function onSubmit() {
        if((g_form.getValue('<variable name>') == 'yes') && this.document.getElementsByClassName('get-attachment').length == 0) {
               g_form.addErrorMessage(getMessage('attachment_is_mandatory'));
               return false;
        }      
}