Get a first look at what's coming. The Developer Passport Australia Release Preview kicks off March 12. Dive in! 

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

snow_beginner
Giga 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

vermaamit16
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

Thanks and Regards
Amit Verma

View solution in original post

6 REPLIES 6

vermaamit16
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

Thanks and Regards
Amit Verma

hi @vermaamit16 @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.

Thanks and Regards
Amit Verma

thanks a lot @vermaamit16 for your quick response!

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