Question

IsRequired

Hello all, I am trying to make one of 2 check boxes required. I am unable to use Business rules as I have and's and or's. I am able to make the Red *'s appear, but when saving it is not enforced.  I have added 2 check boxes to the Activity Mini page. using isRequired Bound  to functions that return true or false the red *'s appear and disappear as expected, but not enforced when completing the Activity. I have also Added isRequired Bound to the Diff as seen in different Posts, but it does not work.  I have looked at many Posts.  Am I missing a step?

attributes: {
			"UsrisVirtual" : {
				"isRequired": {"bindTo": "isRequired1"},
				},
			"UsrIsinperson"  : {
				"isRequired": {"bindTo": "isRequired2"}
			}
isRequired1: function() {
				if (this.get("ActivityCategory")== 'First Consultation' |this.get("ActivityCategory")== 'Second Consultation' |this.get("ActivityCategory")== 'Consultation' | this.get("UsrIsinperson")== false && this.get("UsrNeedNP") == "New Pool")  {
 
					return true;
 
				}else{
					return false;
				}
 
			},
			isRequired2: function() {
				if (this.get("ActivityCategory")== 'First Consultation' |this.get("ActivityCategory")== 'Second Consultation' |this.get("ActivityCategory")== 'Consultation' | this.get("UsrisVirtual")== false && this.get("UsrNeedNP") == "New Pool" ) {
					return true;
				}else{
					return false;
				}
 
			},
 

 

Like 0

Like

5 comments

Hello Keith,

 

Thank you for your question. Please share the complete code of the Mini Page so we have more context of the situation.

 

Best Regards,

Dan

Hello Keith,

 

I looked deeper into your need and checked the documentation. In your situation "IsRequired" would not be an optimal solution.

 

Please consider using validators instead:

https://academy.creatio.com/docs/developer/getting_started/develop_appl…

 

Here is an example for MiniPage (it has a slight difference). In the example, the logic would require users to check UsrBoolean1 if Priority is High and the Category is To Do.

 

methods: {
			setValidationConfig: function() {
                this.callParent(arguments);
                this.addColumnValidator("UsrBoolean1", this.boolean1Validator);
            },
 
            boolean1Validator: function() {
                var invalidMessage= "";
 
                var usrBool1ColumnState = this.get("UsrBoolean1");
 
                var activityCategory = this.get("ActivityCategory");
                var activityCategoryDisplayValue = "";
                if (activityCategory) {
                    activityCategoryDisplayValue = activityCategory.displayValue;
                }
 
                var activityPriority = this.get("Priority");
                var activityPriorityDisplayValue = "";
                if (activityPriority) {
                    activityPriorityDisplayValue = activityPriority.displayValue;
                }
 
                var validActivityCategory = activityCategoryDisplayValue == "To do";
                var validPriority = activityPriorityDisplayValue == "High";
 
                if (validActivityCategory && validPriority && !usrBool1ColumnState) {
                    invalidMessage = "Top Priority column should be checked!";
                    Terrasoft.showMessage(invalidMessage);
                } else {
                    invalidMessage = "";
                }
 
                return {
                    invalidMessage: invalidMessage
                };
            }
		},

Please pay special attention to 

                    Terrasoft.showMessage(invalidMessage);

Since you are using MiniPage - the PopUp window is disabled and you need to call it manually.

 

Another difference that is worth noticing - you should add the condition that the Boolean field is empty (so it does not soft lock you)

 

Other than that - the logic is similar.

 

Best Regards,

Dan

Denis Bidukha,

Thank you, I ended up overwiting the save function as I did not know that " the PopUp window is disabled"  when using setValidationConfig as I tried that as well. I will see if this works better.  Many thanks

Denis Bidukha,

So trying this, and it is firing as the Minipage opens, so there is no way to check the boxes.   Am I missing something?

 

			setValidationConfig: function() {
				this.callParent(arguments);
				 this.addColumnValidator("UsrIsinperson", this.test);		
			},
 
			test: function() {				
					if (!this.get("UsrIsinperson") && !this.get("UsrisVirtual")  ) {
				invalidMessage = "Please Check one of the boxes";
				    Terrasoft.showMessage(invalidMessage);
                } else {
                    invalidMessage = "";
                }
 
			return {
                    invalidMessage: invalidMessage
                };
 
 
			},
 

 

Denis Bidukha,

Thank you, Got it working.

setValidationConfig: function() {
				this.callParent(arguments);
				 this.addColumnValidator("UsrIsinperson", this.test);
				 this.addColumnValidator("UsrisVirtual", this.test);
			},
 
test: function() {	
				if (!this.get("UsrIsinperson") && !this.get("UsrisVirtual") && this.get("UsrNeedNP") == "something" && this.isConsultation()) {
					invalidMessage = "Please Check one of the boxes";
				    Terrasoft.showMessage(invalidMessage);
 
				}else if (this.get("UsrIsinperson") && this.get("UsrisVirtual") && this.get("UsrNeedNP") == "somethingl" && this.isConsultation()) {
						invalidMessage = "Please Check ONLY one of the boxes";
						 Terrasoft.showMessage(invalidMessage);
 
                } else {
                    invalidMessage = "";
                }
 
			return {
                    invalidMessage: invalidMessage
                };		
			},

 

Show all comments