260
Views
5
Comments
Solved
Inside list i have form i want to validate the input field of form
Question
Application Type
Reactive
Service Studio Version
11.54.5 (Build 62302)

I have list inside list i have drag form and in form there is some input field 

i want to check some validation on change of input field i have applied validation using regex after that i want to make input field property valid or invalid on basis of regex output but i am unable to get the valid widgit property inside widgit folder because form is inside list so it will not shown there how i can make invalid that field and show error message .  


2021-09-06 15-09-53
Dorine Boudry
 
MVP
Solution

Hi @Mohammed Rizwan ,

you can't directly address in your low code action flow the valid property and validation message of the widgets that are inside a list.

One of the solutions is putting your inputs inside a webblock, giving you access to the valid properties within the scope of that block, but that gets messy with having to signal all changes with events up to the parent form. 

Alternatively, Outsystems offers a javascript API to invalidate a widget, so the thing you need to solve is the link between a variable in your list that you find some fault with, and the corresponding html element.  

One of the ways you can do this, is to give the elements a distinguishing property that involves the rownumber and the input within that row, and use that same distinguishing property to invalidate them with the Validation api.

See attached oml.

1) local variables with default value a unique string for each input :

2) give each input an attribute with a unique name built up from that local + rownumber

3) in your save logic, you will have some sort of iteration over your list, validating all inputs in them, when finding a problem, call a screen action to invalidate that particular input in that particular row

4) pass to that invalidation logic the message to show, and the unique combination of fieldname (local variable) + rownumber

5) the invalidation itself happens through the outsystems validation api, using the unique name to find the widget to invalidate.


Dorine


QDR_ListValidation.oml
2023-10-26 15-12-53
Mohammed Rizwan

I have make it done  thanks for your efforts to explain in detail for solutions .

2022-04-25 10-23-04
edTheEngineer

Hi,

Perhaps put the Form with input in a Web Block and call that web block within the list. 


That should allow you to access it. Hopefully there will be no unexpected behaviours. Not sure why this isn't available in the platform



2021-09-06 15-09-53
Dorine Boudry
 
MVP
Solution

Hi @Mohammed Rizwan ,

you can't directly address in your low code action flow the valid property and validation message of the widgets that are inside a list.

One of the solutions is putting your inputs inside a webblock, giving you access to the valid properties within the scope of that block, but that gets messy with having to signal all changes with events up to the parent form. 

Alternatively, Outsystems offers a javascript API to invalidate a widget, so the thing you need to solve is the link between a variable in your list that you find some fault with, and the corresponding html element.  

One of the ways you can do this, is to give the elements a distinguishing property that involves the rownumber and the input within that row, and use that same distinguishing property to invalidate them with the Validation api.

See attached oml.

1) local variables with default value a unique string for each input :

2) give each input an attribute with a unique name built up from that local + rownumber

3) in your save logic, you will have some sort of iteration over your list, validating all inputs in them, when finding a problem, call a screen action to invalidate that particular input in that particular row

4) pass to that invalidation logic the message to show, and the unique combination of fieldname (local variable) + rownumber

5) the invalidation itself happens through the outsystems validation api, using the unique name to find the widget to invalidate.


Dorine


QDR_ListValidation.oml
2023-10-26 15-12-53
Mohammed Rizwan

I have make it done  thanks for your efforts to explain in detail for solutions .

2019-04-01 08-29-26
Paul Reuvers

This works great, thanks.

Only downside is, the client action had to be in the screen. Tried it under the logic tab, but I got errors, "Cannot read properties of null (reading 'widgets')" and "this._model is null". Last one is from a personal environment.

So just wanted to add to this. 

Maybe someone has a way or idea to use this more globally? (Other than blocks)

Regards,
Paul

2021-09-06 15-09-53
Dorine Boudry
 
MVP

Hi Paul,

Agree, sadly this is true for anything you want to do with the $public api.

I have searched a considerable amount of time on a way to write reusable client actions interacting with the $public api, haven't found anything clean yet.  

The $public exists within the scope of a particular screen or block.  You could make an object variable referencing it, and pass that into a reusable client action.  For more complex logic, that makes a lot of sense.  

But for this example, you are still stuck with needing a javascript node in each screen or block, producing that object variable, to pass it into a client action that, in this case, consists of only one line of code in a javascript node, so potato potato...

Dorine

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.