To Make attachment mandatory on Catalog Item Back end and Portal

Vamsi43
Tera Contributor

Hello Team,

 

My requirement is to make and attachment mandatory based on the value of any catalog variables. I saw many proposed articles in community to do it via DOM manipulation technique.

where this technique is not good to use as per ServiceNow recommendation. Is there any other possible way to make this work ? 

 

Thanks.

1 ACCEPTED SOLUTION

I don't know of an alternate approach that works with Service Portal.  You can make attachment variables show at the top of the form instead of the activity stream by creating an async, Insert Business Rule on the sc_req_item table.  The script looks like this:

(function executeRule(current, previous /*null when async*/) {
	var attach = new GlideRecord('sys_attachment');
	attach.addQuery('table_name', 'ZZ_YY' + current.getTableName());
	attach.addQuery('table_sys_id', current.sys_id);
	attach.query();
	while(attach.next()){
		attach.table_name = current.getTableName();
		attach.update();
	}
})(current, previous);

View solution in original post

3 REPLIES 3

Brad Bowman
Kilo Patron
Kilo Patron

Create a variable that has the type of attachment, then make that variable mandatory based on another variable(s) via Catalog UI Policy or Catalog Client Script.

I tried implementing this but the attachment is not shown on top of the Request item. The attachment is shown in variables editor. 

Can't we use the Glide Form API or a different approach for the solution?

I don't know of an alternate approach that works with Service Portal.  You can make attachment variables show at the top of the form instead of the activity stream by creating an async, Insert Business Rule on the sc_req_item table.  The script looks like this:

(function executeRule(current, previous /*null when async*/) {
	var attach = new GlideRecord('sys_attachment');
	attach.addQuery('table_name', 'ZZ_YY' + current.getTableName());
	attach.addQuery('table_sys_id', current.sys_id);
	attach.query();
	while(attach.next()){
		attach.table_name = current.getTableName();
		attach.update();
	}
})(current, previous);