BR - Error Message based on fields

SD30
Tera Contributor

Hi 

I am creating Business rule for Change request form. while moving the status new to access, we have few mandatory fields.

If the mandatory fields are empty then it should show the error with the field name.

For Ex: If the user didn't Fill the test_plan then I need the error message as "Please fill the test Plan"

below one is standard error message. Error message needs to be changes based on the filed not filled. Please help 

(function executeRule(current, previous /*null when async*/) {

	if (current.implementation_plan.nil() || current.test_plan.nil()){
		gs.addErrorMessage('Please fill the implementation plan and test plan');
		current.setAbortAction(true);
	}

})(current, previous);

 

 

 

1 ACCEPTED SOLUTION

harun_isakovic
Mega Guru

Mandatory fields will be highlighted by default and prevent record submission/update if they are empty. The business rule is unnecessary. But if the customer is pushing it for whatever reason try this:

(function executeRule(current, previous /*null when async*/) {

	if (current.implementation_plan == null || current.test_plan == null){
		gs.addErrorMessage('Please fill the implementation plan and test plan');
		current.setAbortAction(true);
	}

})(current, previous);

View solution in original post

9 REPLIES 9

Hi Muhammad,

Really thank you for your effort. I have mentioned 2 fields, just for an example, I have close to 8 fields.

For all the fields nested if will not be a right choice I guess. 

No worries,

In your UI policy condition you are using as "Status"  greater then or is "Assess". I am not sure this is going to work.

You should use it like status is Assess (or Access).

Hi Muhammad,

I have tried that as well. But issue is not resolved.:-(  

Thank you

harun_isakovic
Mega Guru

Mandatory fields will be highlighted by default and prevent record submission/update if they are empty. The business rule is unnecessary. But if the customer is pushing it for whatever reason try this:

(function executeRule(current, previous /*null when async*/) {

	if (current.implementation_plan == null || current.test_plan == null){
		gs.addErrorMessage('Please fill the implementation plan and test plan');
		current.setAbortAction(true);
	}

})(current, previous);

Hi Harun,

Thank you.= for sharing

If the user didn't Fill the test_plan then I need the error message as "Please fill the test Plan"

Above one is standard error message. Error message needs to be changes based on the filed not filled. Please help