I'd like to find the best way in Maestro to have a field validated by a local synchronous validation Rule first and then, pending the success of a local validation rule, it would make a remote asynchronous request call to a Dynamic Data Service which would return if the input to the DDS was valid or not and display a validation error message for invalid input.

The main issue with this approach is that the local synchronous validation rule is called multiple times indeterminately, including after the remote asynchronous call to a DDS which could display it's own validation message. If the local validation is called again after the remote validation, it will overwrite the remote validation message with either its own validation message or nothing if the first validation rule passes.

Below is the best approach I have come up with. I have a standard local validation rule that is being called at indeterminate times and a change rule that will make a remote DDS call and then explicitly call the local validation rule to pass a message if the input for the DDS call is invalid.


Validation rule for Text field C.P.
if (data.cpValidationMessage) {
    return data.cpValidationMessage
} else {
    var regex = new RegExp('^\\d{5}$', '');
    return regex.test(value) || 'C.P. debe tener 5 dígitos exactos';
Change rule for Text field C.P.
var inputFieldRefs = [{
    key: "CP",
    ref: "data.cp"
var outputFieldRefs = [{
    key: "colonias",
    ref: "data.coloniaDataField"
}, {
    key: "estadosName",
    ref: "data.estadosName"
var serviceName = "Blake - Zipcode Lookup";
var dataParams = Form.convertToFieldDataMap(inputFieldRefs, data);
if (data.cp && data.cp.length === 5) {
var validationFunction = this.ok_cp;
// Lookup promise
function proceed() {
    Form.showProgress("Cargando colonias");
    DynamicData.call(serviceName, dataParams).then(function(response) {
        Form.setFieldDataFromResponse(outputFieldRefs, response, data);
        if (response.status === "Invalid") {
            // Save validation message to check for it's existence in local validation rule, so we don't
            // overwrite the validation message
            data.cpValidationMessage = "Código postal no pudo ser validado"
            // Call validation function for CP field and pass a message to display
                validationMessage: data.cpValidationMessage
        } else {
            // Reset the validation message
            data.cpValidationMessage = null;
    }).catch(function(err) {
        console.log("Error: ", err);

In my approach, the problem with the local validation rule being called after the remote validation (and thus overwriting the validation message) is mitigated by putting an if condition in the local validation rule so that it will not execute the local regex validation if a validation message is returned from the remote DDS call.

There has to be a better way to do this. If not, should this be functionality that is supported natively to Maestro?

    CommentAdd your comment...

    1 answer


      Hey Blake,

      Maestro 5.0.17 includes support for this type of validation approach where you wish to validate locally and only validate remotely when the value has been changed.

      You will find a new event type called Validate after change if...

      You can have both a standard (local) validation rule as well as a Validate on Change rule that calls a Dynamic Data service and returns a promise:

      The Validate on Change rule will be triggered only when the local validation has passed and the value in the field has changed.

      1. Ben Warner

        Hey Blake, did this new event type satisfy your requirement?

      2. Umakanta Dalai

        Thanks lot Ben, This Worked for me

      CommentAdd your comment...