How to make attachment not mandatory based on subcategory in single catalog item

poornima batchu
Tera Expert

Hi all, 

I created a custom catalog item (Record producer) called  " Report an issue" in this catalog item we have a variable called "subcategory" which is a reference type of subcategory table. For this catalog item we made the attachments are mandatory by the mandatory attachments checkbox. However, the requirement is to make the attachment not mandatory only for single subcategory in this catalog item

poornimabatchu_0-1692624017140.png

 

How to configure this so that attachment is not mandatory only for single subcategory.

please help...

thank you

4 REPLIES 4

umaaggarwal
Giga Guru
Giga Guru

Hi,

I would suggest do not make it mandatory on variable level. Instead use 'catalog ui policy' to make mandatory false on a certain condition.

Select 'reverse' if false in ui policy. This way it will be mandatory true on all other conditions

 

 

//Please mark this correct if it helped.

if it is a variable on the form, I can use the catalog ui policy but it is not a variable in the catalog item

poornimabatchu_0-1692629537387.png

 

Ankur Bawiskar
Tera Patron
Tera Patron

@poornima batchu 

you can do this

1) create a variable of type file attachment

2) then make it mandatory based on the value you want

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

Hi ankur, 

I created a variable of attachment type but the attachement added are not showing up on the case but I can find the attachment in the sys_attachment table..I tried the below BR to show the attachments in the case header but it is not working

(function executeRule(current, previous /*null when async*/) {

	// Add your code here
	var gr = new GlideRecord("sys_attachment");
gr.addQuery("table_name", "ZZ_YY" + current.getTableName());
gr.addQuery("table_sys_id", current.sys_id);
gr.query();
if (gr.next()) {
gr.table_name = current.getTableName();
new global.VariableUtil().copyAttachment(gr.sys_id, current.getTableName(), current.sys_id);
gr.update();
}

 

})(current, previous);