Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

Mandate Attachment based on condition

Hemalatha1
Tera Contributor

Hello 

 

I would like to know of there is there any possibility to make the Attachment mandatory based on the variable choices (like Yes or No) in Record Producer .

 

3 REPLIES 3

johnfeist
Mega Sage

Hi Hemalatha,

If you are looking to do this via a catalog item, the answer is yes you can.  There is a variable type of attachment.  You can include such a variable on your form and when the appropriate question is set have a catalog client script or catalog ui policy make it visible and mandatory.

Hope that helps.

:{)

Helpful and Correct tags are appreciated and help others to find information faster

Hope that helps.

:{)

Helpful and Correct tags are appreciated and help others to find information faster

Harish KM
Kilo Patron
Kilo Patron

Hi here is the client script

function onSubmit()

{

if ( g_form.getValue('type') == "yes") { var alertWord = "attachmentmandatory.";

try {

var attachments = g_form.getControl('header_attachment_list_label');

if (attachments.style.visibility == 'hidden' || attachments.style.display == 'none' ) { alert(alertWord); return false; } } catch (e) { //For Service Portal var count = getSCAttachmentCount(); if (count <= 0) { alert(alertWord); return false; } } } } <

Regards
Harish

Logan Poynter
Mega Sage

Hello,

You can do this with a Catalog UI Policy - no scripting necessary. Set your UI Policy conditions to the variable choice value and then an appropriate action to make the attachment field mandatory. 


Please mark my answer as correct/helpful if it has helped you.

Thanks,
Logan
--
LinkedIn