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
what is the type of ri!REGAL_documents? If it is of type "Any type" cast it to your CDT first then try.