Attachment mandatory for particular field

Community Alums
Not applicable

Hi All,

I have a field called Attachment, In that I have 3 choices i.e Test1 Test2 and Test3

if I select Test1 and Test2, 

Error message should display attachemt is manadatory

if I select Test3

it should not give any error

Note: Only for Test1 and Test2 only we have the attachment not for entire form.

could you please help on this

Thanks

1 ACCEPTED SOLUTION

@Community Alums  Thanks for marking my answer as helpful. If it helped you in any way please accept the solution so that it will be beneficial to the future readers with the same query.

 

Regards,

Swathi Sarang

View solution in original post

7 REPLIES 7

Sohail Khilji
Kilo Patron
Kilo Patron

Hi @Community Alums ,

 

var checkVal = g_form.getValue(''u_attachement); // your field here

if(checkVal == 'Test1' || checkVal  == 'Test2' ){ // check if the value is test1 or test 2

if (this.document.getElementsByClassName('get-attachment').length == 0) {
		g_form.addErrorMessage(getMessage('attachment_mandatory'));
	}	


}

☑️ Please mark responses as HELPFUL or ACCEPT SOLUTION to assist future users in finding the right solution....

LinkedIn - Lets Connect

swathisarang98
Giga Sage
Giga Sage

Hi @Community Alums ,

 

You can create on submit catalog client script,

swathisarang98_0-1715167106058.png

 

function onSubmit() {
  
	if((g_form.getValue('attachment') == 'test1' ||(g_form.getValue('attachment') == 'test2')) && this.document.getElementsByClassName('get-attachment').length == 0) {
		g_form.addErrorMessage(getMessage('Attachment is mandatory'));
		alert('Attachment is mandatory');
		return false;
	}	
}

 

 

Please mark this comment as Correct Answer/Helpful if it helped you.

Regards,

Swathi Sarang

@Community Alums  Thanks for marking my answer as helpful. If it helped you in any way please accept the solution so that it will be beneficial to the future readers with the same query.

 

Regards,

Swathi Sarang