Hi,
I have an interface with editable grid (a!gridLayout) where I am trying to add a new row with required elements when user clicks on "Add Dcoument".
I have to achieve the below requirements. Not 100% sure whether it can be done or not.
1. If any one of the field / element filled with data, other fields/elements should be filled with.
2. Also, there should not be any row with empty empty fields/elements.
When I try to write a validation in the Document Title field, then it is applying to all the rows of that field when I click on the "Add Document". Not sure how to handle for row by row.
required: if(a!isNotNullOrEmpty(ri!Documents.documenttype),true(),false())
Discussion posts and replies are publicly visible
The "required" setting for the Title text entry would need to be based on that row's document Type selection - at the moment you're basing it on the value of the entire array, which won't really work well. It should be something along the lines of "fv!item.documentType" in your example. Basically the same thing that you're (hopefully) saving the row-specific document type value into.
Thanks Mike for providing an idea to handle the validations in this scenario..
Is there away we can handle if entire row is empty. Is it advisable to handle at grid level or something at Process Model smart node level?
Can you specify what you mean exaclty by "entire row is empty"? What would the validation condition be exactly / what would you want to show the user / what would you hope the user does differently? Generally, when a row is added and you make all 3 of the column-fields required, when they attempt to "submit", the item-by-item 'required' messages will show.
I mean, if any of the row (All elements) left empty and try to submit the form, then I would like to provide validation.
Not sure how to handle this.
Also, by default, I am showing one row with all the three elements. Is it mandatory to show at least one row in the editable grid?
swapnar6405 said:if any of the row (All elements) left empty and try to submit the form, then I would like to provide validation.
Setting the "required" parameter on any / all of the fields should accomplish this. Generally I recommend you stick to this approach unless you have strong reasoning to do otherwise.
swapnar6405 said:Is it mandatory to show at least one row in the editable grid?
No. If you want to start out with an empty grid (until the user clicks "add"), you should make sure to pass in an empty set as your initial CDT value.
When I try to show an empty grid initially when the page/interface load and if I try to add a new row when user clicks on "add", I am getting an error message
"Could not display interface. Please check definition and inputs. Interface Definition: Expression evaluation error [evaluation ID = 59651:353c2] : An error occurred while executing a save: java.lang.IllegalArgumentException: Invalid index: Cannot index property 'documenttype' into type List of Null"
Please share a code snippet - there's something you're not initializing correctly, but it's hard to tell based only on front-end screenshots
Test code
You need to initialize local!intakedocuments as an empty set ({}), not null. The a!forEach() function properly handles an empty set, but if you pass a value of null(), it'll assume that's an actual (empty) row with invalid properties, producing the error you're seeing.
Even after using empty set {}, I am getting same error.
This error is occuring, then I try to add a new row by clicking on "add" link and after selecting an item in the first column drop down element value.
You'll also want to replace this "save!value" (which is empty) with your CDT type declaration. This will mean you're appending one row containing that empty CDT (instead of null) to the end of the array (which, when the array is starting blank, will mean it's just an array of a single empty copy of htat CDT, which is what you'llw ant).