K2 SmartForms List View - required fields

  • 14 November 2012
  • 17 replies
  • 36 views

Badge +2

Hi All,

I'm trying to add  some validation to my list view and cant seem to find a solution, hopefully someone can help.

I've created a List View of a SmartObject and enabled the  List Editing allowing a user to edit and add new records rows and now i would like to validate that the required fields have data before the item is added to the list.


Thanks in advance for your assistance.


17 replies

Userlevel 1
Badge +3

You need to add a condition to the rule that you want to action on (in example below on Save). Search for condition: "the form passes validation". There you can set if fields are required and if the have to conform the validation pattern (that is set on the control itself).


Badge +2

I am running into the same issue. I can understand that this will work in case of a form that persists its own data.


But if you want to use validation in a workflow scenario, I don't see this working. We would like to use the automatic generated workflow header and submit functionality. The proper event I would expect to be present is: OnWorkflowSubmit or something like that. In that case, on submit, the validation can be checked -> success? complete the submit ; not valid? --> stay in the form and show the missing fields.


Now only an AfterSubmit event is available and if you use the validation step in there.. the workflow has already moved to the next step.


I understand I can choose not to use the automatic generated workflow header and use customer buttons instead (e.g. a save button), but if I want to do that, and I want to move to the next WF step by clicking on a button, I need to add WF activity knowledge to the form. That is feeling unnatural and prevents me reusing the form. Or is this the time that States kick in?

Badge +9

Hi Eric, this is great feedback! Can you perhaps
log this as product feedback via the customer and partner portal.

Badge +2

Thanks for the feedback guys.

Unfortunitly when testing this it was discovered that only the last record was validated.


To better explain my senario,

I have a list which i enter multiple records that i want validated to ensure that certain fields are populated in every record.


A huge win would be if this validation could occur as the record comes out of edit mode and enters the read mode in the list.


 


Thanks All! 

Badge +4

You need to edit the "When the View executed List item Added" and "When the View executed List item changed" rules, to include a condition to check that "form passes validation". Then on the form validation configuration specify which fields are required and which must be validated based on their data type or validation pattern specified on the controls.


I tried this and it does not allow me to add a row if the validation does not pass correctly.


17097i8675C4FDD01D5280.png
Badge +2

It's getting even better:


I've decided to let go of the Pre-Submit approach (since it's not there (yet?)) and built my own Submit button. Added a validation step, selected my fields to validate.. Finished, check-in.


Not working.


Checked my Form.. all validation was gone! Redid the validation, finish.. Edit the form again.. validation still there. Check-in? Edit -> all validation was gone.


How should I get this to work?

Badge +2

Hi Eric,

I came across this aswell the validation configuration in not persisting.

What i did was once i finish the validation rule then a saved the form and clicked finish on the form.


This is only a tempory fix because once you enter that rule configuration again then the values are lost.

Badge +2

Thanks Sam. This was exactly what i was looking for and it works!

Great job!! 

Badge +4

I'm facing exactly the same. Whenever I check in the form I loose all the validation in the 'form passes validation'.


Any workaround ? Avoiding to specify a if for each field..

Badge +4

I would suggest that you first try to refresh your browser cache and then reconfigure the condition/rule.

Badge +4

It was identified as bug by K2.


There is already a patch to fix it. In case you face it, get in touch with K2 support.


 

Badge +4

Hi Samuel, by any chance do you know how to define default values for the new "add row"


Thanks in advance


Karina

Badge +4

The control properties will have a "Default Value" or "Text" property that you can set to specify the default value.

Badge +10

@All the people losing validation.

 

I think this was a bug before the 4.6.4 release, if i remember correctly. It has been fixed in the subsequet releases.

 

 

Badge +6

Hi Sam,

 

Your solution sounds good but problem is it validates only last row. However it should be if the drop down control is null or no value is selected then it should disply validate error message immediately after row is over/finished or on click of Add new row.

The screenshots will clear the picture-

Clarity role is mandatory, if no item is selected for this and values are entered in project Responsibility or Total Days, then error message should appear.

Any help will be highly appreciated.

 

14192i52D782AA8C0D84E5.png

Userlevel 5
Badge +16

Hi RamKumar,

 

I would like to suggest my way to validate a list view, It needs a bit more work.

 

Here is an example 

 

I have list view and I create another Item View to add items to the list, it much easier to control validation on the item view

 

so when the user click ADD it will open the item view as a subview, there should be an add button on the item view that has the following rules:

 

when btnAdd is Clicked

 

If view Passes Validation

 

Add new row to the list 

transfare data to the list (here you transfare the what you user entered)

submit changes on the row

Close subview

 

now I explaine what if the user clicked edit

 

When edit toolbar button is clicked

 

edit selected row

open subview (when configure, tranfare the row data to the item controls to fill it)

 

now you need to add the same rules when add button on the item view is clicked with a change

 

instead of "Add new row" set "Edit selected row"

 

 

Note: if you want to do this you need to add the same rule of the edit on list item double click or just remove the double click rule

 

and disable "Add new row link"

 

whis it helps

 

 

Badge +1

Hi Mustafa,

 

 

On the item form subview, are the only rules you have on btnAdd the validation and then the close subform/subview rule? Then the other rules (adding of the rows, transferring of data and applying the row rules) are done from the calling form/view? I can't see it working any other way so just wanted to make sure because the validation rule can't be the only rule on the btnAdd item subview and the adding rows/transferring data/applying rule need to be done from the calling view to work with the editable list.

 

Reply