Field Visibility Property

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