Mandatory Attachment on Submit based on Catalog Item Variable

gnunez
Kilo Guru

Hello all,

I have a requirement to make an attachment mandatory on submit based on a catalog item variable.

The question is: Are you requesting to relocate more than one phone? (relocate_phone)

If yes: attachment is required

If no: attachment is not required

In the past when making an attachment mandatory in a catalog task I have used business rules or catalog client scripts but in this case I cannot figure it out.

Can anyone assist?

Thanks,

Grace

14 REPLIES 14

Mike Patel
Tera Sage

try something like

function onSubmit() {
	var count = getSCAttachmentCount();
	if(g_form.getValue('youryesno field name') == 'yes'){
		if(count <= 0) {
			alert('Please attach your spreadsheet.');
			g_form.addErrorMessage('Please attach your spreadsheet.');
			return false;
		}
	}
}

Thanks for the reply Mike!

I tried your solution and it won't allow the user to submit for either option and no alert message is displayed.

Did you change the variables ? Are you doing this on portal?

Yes I have the below and no we are not on the service portal yet: