Hi All,
I'm getting below expression error when trying to create a grid to display comments or documents. Please suggest how can I resolve this error? Thanks in advance.
Error: Could not display interface. Please check definition and inputs. Interface Definition: Expression evaluation error at function a!forEach [line 89]: “Invalid index: Cannot index property ’’documentId’’ of type String into type List of Variant
/*Choice variable has two values 1 --> Documents (Comments CDT is empty) 2 --> Comments (Documents CDT is empty) */ load( local!choice: if( rule!APN_isBlank( ri!REGAL_comment ), 1, 2 ), local!pagingInfo: a!pagingInfo( 1, 5, a!sortInfo( field: if( local!choice = 1, "createDateTime", "createdDateTime" ), ascending: false ) ), local!switch: true, with( local!dataSubset: if( local!choice = 1, todatasubset( ri!REGAL_documents, local!pagingInfo ), todatasubset( ri!REGAL_comment, local!pagingInfo ) ), { a!richTextDisplayField( /*label: local!switch,*/ value: a!richTextItem( text: if( local!switch, "Hide ", "Show " ) & if( local!choice = 1, "Documents History", "Comments History" ), style: { "EMPHASIS", "STRONG" }, link: a!dynamicLink( saveInto: a!save( local!switch, if( local!switch, false, true ) ) ), linkStyle: "STANDALONE" ), showWhen: ri!readFromRecord = false ), a!gridField_19r1( columns: if( local!choice = 1, /*Documents Grid*/ { a!gridTextColumn( label: "Document Name", field: "documentName", data: a!forEach( items: index( local!dataSubset.data, "documentId", null ), expression: document( fv!item, "name" ) ), links: a!forEach( items: local!dataSubset.data.documentId, expression: a!documentDownloadLink( document: todocument( fv!item ) ) ) ), a!gridTextColumn( label: "Uploaded By", field: "createdBy", data: a!forEach( items: index( local!dataSubset.data, "createdBy", null ), expression: user( fv!item, "firstName" ) & " " & user( fv!item, "lastName" ) ) ), a!gridTextColumn( label: "Uploaded On", field: "createDateTime", data: index( local!dataSubset.data, "createDateTime", null ) ), a!gridImageColumn( label: "", field: "documentId", data: a!forEach( items: index( local!dataSubset.data, "documentId", null ), expression: a!documentImage( document: a!iconIndicator( "REMOVE" ), caption: "Remove Document", link: a!dynamicLink( value: fv!index, saveInto: { a!startProcess( processModel: cons!DELETE_DOCUMENT, processParameters: { document: ri!REGAL_documents.documentId[fv!index] }, onSuccess: { a!save( ri!REGAL_documents, remove( ri!REGAL_documents, fv!index ) ) } ) } ) ) ), showWhen: false/*ri!isInitiator = true()*/ ) }, /*Comments Grid*/ { a!gridTextColumn( label: "Comment", field: "commentDescription", data: index( local!dataSubset.data, "commentDescription", null ) ), a!gridTextColumn( label: "Commented By", field: "createdBy", data: a!forEach( items: index( local!dataSubset.data, "createdBy", null ), expression: if( rule!APN_isBlank( fv!item ), fv!item, user( fv!item, "firstName" ) & " " & user( fv!item, "lastName" ) ) ) ), a!gridTextColumn( label: "Commented On", field: "createdDateTime", data: index( local!dataSubset.data, "createdDateTime", null ) ) } ), totalCount: local!dataSubset.totalCount, value: local!pagingInfo, saveInto: local!pagingInfo, showWhen: local!switch ) } ) )
Discussion posts and replies are publicly visible
In addition to what already said, I note that you're using `a!gridField_19r1` in your interface, implying that you're on 19.2 or higher - in which case, I strongly suggest you look into using the new style paging grid instead, as it's far easier to configure (for example, for your first column, in the new style grid you wouldn't need to loop over your data set once for the data: parameter and again for the links: parameter...)
This would pay off because it would instantly help your debugging efforts for errors like this due to the far simpler configuration.
Yes Mike, I now changed it to the newer paging style grid and its more feasible to debug now. Thank you so much for the suggestion.
We would both appreciate it if you could confirm one or maybe both of our answers.