cancel
Showing results for 
Search instead for 
Did you mean: 

Error message on validation script

Former Member
0 Kudos

Hi Guys,

I created a validation script for MA to check the fill on the extention collection as below.

	
productColln = doc.getExtensionCollection("PROD_HIER");
productItr= productColln .iterator();

for(member : productItr){
		
		if(!hasValue(member.get("fieldA"))){
			exception.chainAtEnd(member.createApplicationException("fieldA","Please enter Max Value"));
		}
		if(!hasValue(member.get("fieldB"))){
			exception.chainAtEnd(member.createApplicationException("fieldB","Please enter the Unit Price"));
		}			
	}

if(exception.getChain() != null){
    throw exception.getChain();
}


1. When the 'fieldA' and 'filedB' are blank, the error message is shown only for 'fieldA'. After i complete 'fieldA' the error message will be shown for 'fieldB'. It seem like it will show only for first one which is put in the chain. I would like the message to show all message in the chain.

2. When the error message is shown the both fileds are covered by the red line but i would to have the red ' ! ' appear on the tab (ex. for product tab) as well. How can i implement that?

Noppong,

Thank you in advance

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi

In order to resolve first issue I would suggest intrducing an addtional if statement at the beginning of the loop using && operator, something like * if(!(hasValue(member.get("fieldA"))) && !(hasValue(member.get("fieldB"))) ) *

This would take care of all three scenarios

Regards

Mudit Saini

Former Member
0 Kudos

Hi Mudit,

The issue is i would like the error message show all the errors which are put in the error chain. It seem like it show only the first one which is put in to the error chain. On the code , if fiedA and fieldB are blank it show only error message for filedA.

Noppong,

Thanks for you reply

Former Member
0 Kudos

Hi Noppong

My understanding is once system gets an exception, it skips to throw statement and the subsequent exceptions, if any ,are skipped. Use of chain exception allows one to write one throw statement in the code rather than multiple throws at various points.

I may be wrong so appreciate if someone can validate this.

Regards

Mudit Saini

Answers (0)