How to make knowledge article attachment mandatory on incident form based on resolution code choice.

snow_beginner
Mega Guru

Hi,

So there is a requirement that if the 'Resolution Code' = Known Error on the incident form then an attachment needs to be mandatory of a Knowledge article. How would I achieve that functionality? To make the (📎) thats on top of the form mandatory, what would be needed?

1 ACCEPTED SOLUTION

Amit Verma
Kilo Patron
Kilo Patron

Hi @snow_beginner 

 

Make a Business Rule as below on the incident table :

 

AmitVerma_0-1706870973727.png

 

AmitVerma_1-1706870993164.png

 

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

    if (current.hasAttachments() != true) {

        gs.addInfoMessage("Please add a relevant knowledge article to proceed!!!");

		current.setAbortAction(true);

    }

})(current, previous);

 

Output :

 

AmitVerma_2-1706871169868.png

 

Thanks & Regards

Amit Verma


Please mark this response as correct and helpful if it assisted you with your question.

View solution in original post

6 REPLIES 6

Amit Verma
Kilo Patron
Kilo Patron

Hi @snow_beginner 

 

Make a Business Rule as below on the incident table :

 

AmitVerma_0-1706870973727.png

 

AmitVerma_1-1706870993164.png

 

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

    if (current.hasAttachments() != true) {

        gs.addInfoMessage("Please add a relevant knowledge article to proceed!!!");

		current.setAbortAction(true);

    }

})(current, previous);

 

Output :

 

AmitVerma_2-1706871169868.png

 

Thanks & Regards

Amit Verma


Please mark this response as correct and helpful if it assisted you with your question.

hi @Amit Verma @snow_beginner - i am new to ServiceNow and working on similar requirement, i have a quick question - can't we use client script for validating attachment while resolving the incident with 'Resolution Code' = Known Error.

just trying to understand if it can be achieve by client side script or need to write business rule as suggested above.

@Akansha Gupta 

 

You can refer below link:https://www.servicenow.com/community/itsm-forum/how-to-check-attachment-before-on-submit-client-scri...

 

Please note that it requires DOM Manipulation which is not recommended.


Please mark this response as correct and helpful if it assisted you with your question.

thanks a lot @Amit Verma for your quick response!

can you please also help m in understanding which one is preferable as per best practice - BR or client script.