Hi Team,

I need to validate 'Amount' field as not having -ve number. But if this field is hidden, then this validation should not work.

------------------------------------------------------------------------------------------------------------------

"validators": {

    "ValidateFieldValue": {

        "type": "usr.ValidateAmountForPositiveValue",

        "params": {

            "message": "Amount must be greater than 0(Zero)."

        }

    }

}

 

"usr.ValidateAmountForPositiveValue": {

    "validator": function (config) {

        return function (control) {

            if (visibilityProperty && control.value < 0) {

                return {

                    "usr.ValidateAmountForPositiveValue": {

                        message: config.message

                    }

                };

            }

        };

    },

    /* Validator parameters. */

    "params": [

        {

            "name": "message"

        }

    ],

    "async": false

}

------------------------------------------------------------------------------------------------------------------

 

Query: How can I get this `visibilityProperty` of field & use it in validator?

(I've used Business Rule to show/hide element instead of custom attribute)

Like 0

Like

1 comments

Hello,

Use the approach I described here https://community.creatio.com/questions/how-read-custom-attribute-or-ot…, but also add the 

const isCodeVisible = await request.$context.getControl("Code").visible;

into the code to check if the "Code" column is visible or no.

Show all comments

Hello,

I created a validation for telephone numbers as explained in this article: Implement the validation of a field value on a page | Creatio Academy
For testing purposes, I added it to the notes field on the contacts form, and it works fine.


However, I want to add the validation to the communications options on the left side of the form.
How do I bind the validation in the viewModelConfigDiff?
Also, only communication options of type "phone number" should be validated.

 

Thanks,

Robert

Like 1

Like

3 comments

Hello,

Currently there is no way to add the validator using the regular approach with the validators property on the schema. However you can try adding it using the formControl for the ContactCommunicationOptionsItems (but note that this will be applied for phones, email, skype and web (in other words for all communication options)).

 

How to add the validator using formControl:

 

  1. Implement the same validator on some separate field on the page
  2. Find this validator in the context of the crt.HandleViewModelAttributeChangeRequest request execution (like request.$context._validators["AccountAccountCategory_List.value"][0]), but replace AccountAccountCategory_List.value with your attribute name on the page to which the validator is added. Also make sure array with only one element is returned (since you can have several validators for the same field and the array of validators can contain more than 1 element thus ...["AccountAccountCategory_List.value"][0] can return another validator.
  3. In the context of the crt.HandleViewModelAttributeChangeRequest request (connected to the change of the ContactCommunicationOptionsItems attribute) add the following code:

request.$context.getControl("ContactCommunicationOptionsItems").formControl.addValidators(request.$context._validators["AccountAccountCategory_List.value"][0])
 

But replace equest.$context._validators["AccountAccountCategory_List.value"][0] with the needed validator.

 

This is the only way to add the validator for this CommunicationOptions component (but once again note that this will be added to all the other communication options). 

Oleg Drobina,

thank you for pointing me in the right direction!

However, I can't get it to run...I used the following code, but the validation won't be triggered:

			{
			    request: "crt.HandleViewModelAttributeChangeRequest",
			    handler: async (request, next) =&gt; {
					if (request.attributeName === 'ContactCommunicationOptionsItems') {
						const validators = request.$context._validators;
						const telValidator = validators["StringAttribute_cuzyv0b"]?.[0];
						if (telValidator) {
							request.$context.getControl("ContactCommunicationOptionsItems").formControl.addValidators(telValidator);	
						}
					}					
			        return true;
			    }
			}

What's also strange is that when the handler is executed again (after I changed the field value), all properties of the formControl related to validation (asyncValidator, validator, _rawValidators, _rawAsyncValidators) are empty again!

Any idea what could go wrong here?

Thanks,

Robert

 

Robert Pordes,

Unfortunately no, this was the way I used locally and that worked and maybe the difference may arrise in the application version that was used for tests (8.2.2 in my case) or in other handlers maybe. This should be debugged only, there is no other way to identify what's wrong.

Show all comments

Hey,
I'm working on a use case where I created a section 'Concert'. When I open any concert record It has some records related to 'Performance Detail'

 

Now I have to perform validation on PF_Duration Column. The Query is following:
"Perform verification whenever user adds or modifies a performance as follows: if the total duration of the concert performances exceeds the system setting value (see above), saving a performance record should not be permitted. Instead, a user should receive a message informing that no more than “N” total performances duration is allowed. “N” is the system setting value." 
N = 150 minutes

Like 0

Like

1 comments

Hi Community,

 

I am trying to add a field validation via javascript code using the below article.

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

 

While I am trying the validation, I am getting an error in the console as in the screenshot below. It says "Cannot read properties of undefined (reading 'invalidMessage')." I am initiating a null value in the method as described in the above article. What am I missing here? I cannot add validation to any fields because of this error. I have also added my code snippet below.

 

onEntityInitialized: function() {
				this.callParent(arguments);
				this.onBooleanChange();
				this.changeColor();
				this.setYearEnd();
				this.setNumberOfDaysInApplicationCreationStage();
				this.accountHolderValidator();
			},
 
			setValidationConfig: function() {
				this.callParent(arguments);
				//this.addColumnValidator("BEALMDateofBirth", this.dateOfBirthValidator);
				this.addColumnValidator("BEALMAccountHolderType", this.accountHolderValidator);
			},
 
			accountHolderValidator: function() {
				var invalidMessage = "";
				var lead = this.get("BEALMLead").value;
				var scope = this;
				var esq = Ext.create("Terrasoft.EntitySchemaQuery", {
					rootSchemaName: "Lead"
				});
				esq.addColumn("Id");
				esq.addColumn("BEALMIsPAHExist");
 
				var esqFilter = esq.createColumnFilterWithParameter(Terrasoft.ComparisonType.EQUAL, "Id", lead);
				esq.filters.add("esqFilter", esqFilter);
 
				esq.getEntityCollection(function (result) {
					if (result.success) {
						var isPAHExist = result.collection.collection.items[0].values.BEALMIsPAHExist;
						if (isPAHExist == true) {
							invalidMessage = this.get("Resources.Strings.BEALMInvalidAccountHolderMessage");
						}
						else {
							invalidMessage = "";
						}
						return {
							invalidMessage: invalidMessage
						};
					}
				});
			},

 

Please help to resolve this issue.

 

Thank you

Cheers!

Like 0

Like

2 comments
Best reply

There are two issues:

1) You're not including the scope in your ESQ so in the callback it no longer knows what "this" is. Change to this: 

esq.getEntityCollection(function (result) {
    // stuff here
}, this);  // &lt;- notice passing this scope 

2) Regardless of the missing "this" scope, this will not work since the ESQ is asynchronous. You'll need to use asyncValidate instead. I have an article on how to do that here: https://customerfx.com/article/asynchonous-validation-on-pages-in-creat…

Ryan

 

There are two issues:

1) You're not including the scope in your ESQ so in the callback it no longer knows what "this" is. Change to this: 

esq.getEntityCollection(function (result) {
    // stuff here
}, this);  // &lt;- notice passing this scope 

2) Regardless of the missing "this" scope, this will not work since the ESQ is asynchronous. You'll need to use asyncValidate instead. I have an article on how to do that here: https://customerfx.com/article/asynchonous-validation-on-pages-in-creat…

Ryan

 

Hi Ryan,

 

Thank you very much for the support. That worked like a charm.

Show all comments

Hello Community, 

 

I have a requirement to validate a Column in the editable detail.

How can we achieve this? I tried using validators with the column name of Datagrid. But it didn't worked.

 Any suggestions is really helpful. 

 

Thanks

Gargeyi.G

File attachments
Like 0

Like

3 comments

Hello,

In order to add validation to an editable detail you need to override the method save() in the detail page, for example:

define("UsrSchema1051cea3Page", [], function() {
	return {
		entitySchemaName: "UsrTestDetObj",
		attributes: {},
		modules: /**SCHEMA_MODULES*/{}/**SCHEMA_MODULES*/,
		details: /**SCHEMA_DETAILS*/{}/**SCHEMA_DETAILS*/,
		businessRules: /**SCHEMA_BUSINESS_RULES*/{}/**SCHEMA_BUSINESS_RULES*/,
		methods: {
			save: function() {
                    if (this.get("UsrName") == "1") {
                        this.callParent(arguments);
                    } else {
                        this.showInformationDialog("UsrName should be 1 ");
                    }
                }
		},
		dataModels: /**SCHEMA_DATA_MODELS*/{}/**SCHEMA_DATA_MODELS*/,
		diff: /**SCHEMA_DIFF*/[]/**SCHEMA_DIFF*/
	};
});

 

Hello, 

 

Thankyou for your response, 

But I wanted to validate columns in the detail,

I don't open the detail page and so I don't want to validate in the detail page but in the inline record.

please find attached screenshot

Hi,

This example is working on a detail itself.

With it, you cannot save the record unless the condition is met.

Considering the fact that detail fields are virtually generated, this is the best option to add validation.

Show all comments

Is it possible to change the Location of Validation message in Screen ? 

Please See the screenshot. I want to Change the place of the message from bottom to right as this message is covering the Bellow field's text.

Like 0

Like

1 comments

Hello,

 

Thank you for reporting this issue to us!

 

Unfortunately, the described behavior cannot be improved with a help of basic system tools as of now, but we have already registered a query for our responsible R&D team to improve this functionality in the upcoming releases of the main application. 



Thank you for helping us to make our application better!



Best regards,

Anastasiia

Show all comments

 

Like 1

Like

1 comments
Best reply

Hello Jerome,



The behavior you describe is not an error and corresponds to the basic logic that is inherent in all fields. If the field has the "Required" property and the field type is Number or Fractional, then a value of 0 or 0.00 is an empty value, that is, the field is not filled. Thus, when you try to save a card with 0.00 in a numeric field with the required property, the system will display a message that the field must be filled with a value. The values ​​0 or 0.00 is an empty values, they are displayed in empty fields so that users can visually understand the format of the field. We recommend you remove the mandatory filling from the required field so that you can save the card with a zero value in the field. We will broadcast the information received from you to the development team to consider the possibility of changing the logic of the mandatory filling of numeric fields.



Best Regards,

Kate

Hello Jerome,



The behavior you describe is not an error and corresponds to the basic logic that is inherent in all fields. If the field has the "Required" property and the field type is Number or Fractional, then a value of 0 or 0.00 is an empty value, that is, the field is not filled. Thus, when you try to save a card with 0.00 in a numeric field with the required property, the system will display a message that the field must be filled with a value. The values ​​0 or 0.00 is an empty values, they are displayed in empty fields so that users can visually understand the format of the field. We recommend you remove the mandatory filling from the required field so that you can save the card with a zero value in the field. We will broadcast the information received from you to the development team to consider the possibility of changing the logic of the mandatory filling of numeric fields.



Best Regards,

Kate

Show all comments

We are looking for a for a way to impose a character limitation on a string value that is different than the standard settings. 

 

For example, the user enters a job number as a string and we want to restrict entry to only 10 characters. Is there a way to do this? Obviously not OOTB but with some customization?

Like 0

Like

1 comments

There is a possibility to setup a field validation and this approach is described in this Academy article.

 

Best regards,

Oscar

Show all comments

Hi All,

I need to put validation to restrict the lookup column "Name" to a certain number of characters(not 50,250,500). Can anyone suggest how can i achieve that?

Like 1

Like

3 comments
Best reply

Hello rajat,

 

You can add an event on the object itself through the configuration:

https://prnt.sc/LIjTKY0mxzdz

 

Get the value of the Name field and make sure that it isn't longer than x characters.

 

 

Kind regards,

Yosef

Hello rajat,

 

You can add an event on the object itself through the configuration:

https://prnt.sc/LIjTKY0mxzdz

 

Get the value of the Name field and make sure that it isn't longer than x characters.

 

 

Kind regards,

Yosef

Hi yosef,

I am not able to add anything in that business process. Can you guide me how  to achieve the above objective

 

rajat patidar,

 

Make sure the object exists in your package (custom package is the default one) and then use an event subprocess.

Here's an example on how to work with server side code:

https://academy.creatio.com/docs/developer/interface_elements/record_page/field/add_auto_numbering_to_the_field#title-1349-12

 

You can then follow this logic:

https://academy.creatio.com/docs/developer/interface_elements/record_page/field/add_the_field_validation

 

 

Kind regards,

Yosef

Show all comments

Hello

 

I was trying to validate email format and phone number format in activity section in mobile application but could not find anything.

Please provide me a way to validate these fields in mobile application.

 

Regards,

Malay

Like 0

Like

5 comments

Hello Malay,



Could you please provide us more detailed information on your business task? Could you share screenshots?



Thank you in advance!

 

Best regards,

Bogdan

Hello Bogdan,

 

Hello I want to apply validation for mobile number and email in activity section. For example, the phone number should be of 10 digits and only contain numbers and email format should be of the form abc@xyz.com.

 

I have used JavaScript for lead section to do it for the web version but how to do it for the mobile application?

 

Below is the screenshot of the mobile activity page where I want to apply this validation.

 

Regards,

Malay

Hello Malay,

You can use a custom business rule for this task. See here for an example: https://academy.creatio.com/docs/developer/mobile_development/mobile_ap…

For using the custom rule for validation, you can pass a third parameter to the callback function with a message (the validation message) and value (true or false indicating if validation passed or not).

For example:

var result = {};
if (passedTheTestAndIsValid) {
    result = {
        value: true
    };
}
else {
    result = {
        value: false,
        message: "The entered value is invalid"
    }
}
 
// now include the result in the callback
Ext.callback(callbackConfig.success, callbackConfig.scope, [result]);

Ryan

Ryan Farley,

 Thanks for share it. You have any example using esq query in custom business rules for validations?

Christian Kern,

 

1. File will be stored in configurations.

 

2. The main rule - the first word of business rule name should be the section name. Like "Contact", "Case", "Account". 

 

Best regards, 

 

Bogdan L.

Show all comments