How does "Wait for validation to unlock" work in an input form

Hello,

When yo select this item on the Send button in a form, the form is frozen until an unlock event.
How does the form receive notification that the linked analysis has been completed correctly or not?

I guess that it’s waiting for a field to change state but cannot find where to configure this.

Thanks
Gary

Hi Gary,

Thats exactly what you’ve mentioned, the “Wait for validation to unlock” waits for a Validation field to show up. You can change the type of the input field to become a Validation type (is the last type if I’m not wrong).

I’ve found a post in our community which can help you with the validation field.

Let me know if I could help.

-Guilherme

1 Like

Taking advantage of this topic, I also want to ask if there is a way to use this feedback for another user. Let me explain the use case, for example we have a manager and an operator user, the operator need to change an important value, but the manager user need to know who did that.

Could be better if only with a password could change or input, or something similar to prevent modify sensible data.

It is a form, which means you can add more fields, like a password field for example, and run an analysis before applying the changes to check if user entered the correct password.

Input Form also have a field type User, which you can use to get the user email or user ID.

For all other widgets that are able to trigger an analysis, you also receive in your environment variables the key _user_id. The widget adds this environment variable everytime it triggers an analysis, so you should be able to access it in runtime.

Hello again,

I have a follow up question on form validation regarding multi-user.

I want to release a new blueprint form to my users which has validation (confirmation or rejection messages depending on what the analysis sets the validation field to).

The purpose of the validation, of course, is to inform the user of the form if it worked or not. .

However, the validation field is global (to that blueprint device) so if some other user (userB) has the same form displayed, they also get to see the validation message from userA. This is confusing for userB as they didn’t do anything on the form yet

I cannot think of an of easy way to make the validation field user and form specific - currently it is device specific. Any ideas how this could be implemented?

Thanks
Gary

I don’t there is any easy solution for validations for specific users yet.

What you can do, if you really need it for your application now, is to generate a device for each user, and create Access Rules for them to have only that specific available for a blueprint device.
Then you can use that device for validations on specific customers.

Hi @vitor - yes, I was thinking along those lines as well.

Can you have 2 blueprint devices (one for the real device to get the deviceID and one for the user fields)?

Or I suppose we could just have the one device for each user as you said and then they can select the device they want to influence from the device drop down. In this case, does the access control limit the devices they can see on the device widget within the form?

hi @tago, you can have devices for each customer and record “configuration variables” inside these devices. It will work like a “customer database” to store rules and config data.

Tip: When you create devices for users I suggest you put 2 default tags to identify them, e.g.:
Customer Device:
[
{ key: “device_type”, value: “customer” },
{ key: “customer_id”, value: “612869d4e2cb57f426411e8a”, // any ID generated by you }
]

Hardware Device:
[
{ key: “device_type”, value: “hardware” },
{ key: “device_id”, value: “502869d4e2cb57f426410eab” }, // any id generated by you
{ key: “customer_id”, value: “612869d4e2cb57f426411e8a”, // id of customer that is owner of this hardware }
]

So, these tags will help you to manage your device via script or admin easier.

Lastly, you can improve your visualization (if you want) in your blueprint dashboard.
You select a BP device (customer) and just show the hardware devices from the selected customer. See the images:


Thanks @eger for the suggestion - I’ll have a play with this to see if I can configure it for our use case.

It is a shame that the validation field is device specific (and therefore user global).

Since the validation is normally only useful for that user submitting that form, I wonder how hard it would be to create a ‘form submitting ID’ when the user Submits and then use that ID to only update that form instance with the results of the analysis?

This would make the form validation unique to that form submission

hi @tago,

Try to use the form session-id.

This form tool sends a unique id for each submission and goes to your analysis scope. Below is a code example showing how to use validation with session-id. It should work for you and show the validation to the user that submitted the form.

function validation(validation_var, device) {
  return function _(message, type, device_session) {
    if (!message || !type) throw 'Missing message or type';
    device.insert({
      variable: validation_var,
      value: message,
      metadata: {
        type,
        session_id: device_session ? device_session.value : null,
        show_markdown: true,
      },
    });

    return message;
  };
}

// getting session from analysis scope
const session_id = scope.find(x => x.variable === 'your_session_variable_from_form');
// invoking a new TagoIO device
const my_device = new Device({ token: "your device_token" });
// calling validation funcion
const validate = validation("you_validation_variable", my_device);

// usage examples...
validate("your message warning", "warning", device_session.value); // shows a yellow box validation "warning"
validate("your message danger", "danger", device_session.value); // shows a red box validation "danger"
validate("your message success", "success", device_session.value); // shows a green box validation "success"