Hi All,
I am working on a use case, where I have configured "Remove Document" using a dynamic link in a grid row layout per below code, to remove the uploaded document from the interface. But as soon I click on this Remove link, rule or perhaps grid is throwing this error. Please suggest how can I fix this issue. Thanks a lot in advance
Error:
Interface Definition: Expression evaluation error at function a!forEach [line 115]: Error in a!forEach() expression during iteration 1: Expression evaluation error in rule 'FICO_rule_getimagefordocumenttype' at function 'document' [line 3]: Document Does Not Exist or has been Deleted
Code:
if( rule!APN_isEmpty( ri!FICO_documents ), a!richTextDisplayField( value: { a!richTextItem( text: "No Documents found for this Case", style: { "EMPHASIS", "STRONG" }, size: "MEDIUM", color: "NEGATIVE" ) } ), load( local!pagingInfo: a!pagingInfo( 1, 5, a!sortInfo( field: "createdDateTime", ascending: false ) ), local!switch: true, local!dataSubset: a!forEach( items: ri!FICO_documents, expression: 'type!{urn:com:SVB:types:FICO}FICO_documents'( documentName: fv!item.documentName, createdBy: fv!item.createdBy, createDateTime: fv!item.createDateTime ) ), with( { a!sectionLayout( label: upper( "documents history" ), isCollapsible: true, contents: { a!richTextDisplayField( /*label: local!switch,*/ value: a!richTextItem( text: if( local!switch, "Hide Documents", "Show Documents" ), style: { "STRONG" }, link: a!dynamicLink( saveInto: a!save( local!switch, if( local!switch, false, true ) ) ), linkStyle: "STANDALONE", size: "MEDIUM" ), ), /*Extra Space*/ a!richTextDisplayField(), /*Doc Grid*/ a!columnsLayout( columns: { a!columnLayout( contents: { a!gridLayout( headerCells: { a!gridLayoutHeaderCell( label: "Document" ), a!gridLayoutHeaderCell( label: "Uploaded By" ), a!gridLayoutHeaderCell( label: "Uploaded On" ), a!gridLayoutHeaderCell( label: "Remove", /*showWhen: and(*/ /*isusermemberofgroup(*/ /*loggedInUser(),*/ /*cons!FICO_GROUP_CAS_TEAM*/ /*),*/ /*ri!allowDocDeletion = true*/ /*)*/ ) }, columnConfigs: { a!gridLayoutColumnConfig(), a!gridLayoutColumnConfig(), a!gridLayoutColumnConfig(), a!gridLayoutColumnConfig( width: "NARROW", /*showWhen: and(*/ /*isusermemberofgroup(*/ /*loggedInUser(),*/ /*cons!FICO_GROUP_CAS_TEAM*/ /*),*/ /*ri!allowDocDeletion = true*/ /*)*/ ) }, rows: a!forEach( items: ri!FICO_documents, expression: a!gridRowLayout( id: fv!index, contents: { a!richTextDisplayField( value: { a!richTextItem( text: rule!FICO_RULE_getImageForDocumentType( document: ri!FICO_documents.documentId[fv!index] ) ), a!richTextItem( text: " " ), a!richTextItem( text: if( rule!APN_isBlank( ri!FICO_documents.documentId ), {}, if( contains( touniformstring( getcontentobjectdetailsbyid( ri!FICO_documents.documentId[fv!index] ) ), "No object with this ID has been found" ), "", document( ri!FICO_documents.documentId[fv!index], "name" ) & "." & document( ri!FICO_documents.documentId[fv!index], "extension" ), ) ), link: a!documentDownloadLink( document: ri!FICO_documents.documentId[fv!index] ), linkStyle: "STANDALONE", size: "MEDIUM" ) } ), a!textField( value: ri!FICO_documents.createdBy[fv!index], readOnly: true ), a!textField( value: ri!FICO_documents.createDateTime[fv!index], readOnly: true ), a!imageField( images: a!documentImage( document: a!iconIndicator( "REMOVE" ), caption: "Remove Document", link: a!dynamicLink( value: fv!index, saveInto: { a!startProcess( processModel: cons!FICO_PROCESS_DELETE_FILE, processParameters: { document: ri!FICO_documents.documentId[fv!index] }, onSuccess: { a!save( ri!FICO_documents, remove( ri!FICO_documents, fv!index ) ) } ) } ) ), /*showWhen: and(*/ /*isusermemberofgroup(*/ /*loggedInUser(),*/ /*cons!FICO_GROUP_CAS_TEAM*/ /*),*/ /*ri!allowDocDeletion = true*/ /*)*/ ) } ) ), showWhen: local!switch ), } ), a!columnLayout( contents: { a!forEach( items: ri!FICO_documents, expression: { a!columnsLayout( columns: { a!columnLayout( contents: { a!richTextDisplayField(), a!richTextDisplayField(), a!richTextDisplayField( value: a!richTextItem( text: a!richTextIcon( icon: if( rule!APN_isBlank( local!dataSubset[fv!index].documentId ), "eye", "eye-slash" ), caption: if( rule!APN_isBlank( local!dataSubset[fv!index].documentId ), cons!FICO_TEXT_LABEL_OPEN_DOCUMENT_PREVIEW, cons!FICO_TEXT_LABEL_CLOSE_DOCUMENT_PREVIEW ), color: "ACCENT", size: "LARGE", showWhen: if( or( document( ri!FICO_documents.documentId[fv!index], "extension" ) = "docx", document( ri!FICO_documents.documentId[fv!index], "extension" ) = "pptx", document( ri!FICO_documents.documentId[fv!index], "extension" ) = "xlsx" ), false, true ) ), link: if( rule!APN_isBlank( fv!item.documentId ), a!dynamicLink( saveInto: { a!save( local!dataSubset[fv!index].documentId, ri!FICO_documents[fv!index].documentId ) } ), a!dynamicLink( saveInto: { a!save( local!dataSubset[fv!index].documentId, "" ) } ) ), linkStyle: "STANDALONE" ) ) } ) } ), a!documentViewerField( label: "Document Name: " & document( fv!item.documentId, "name" ) & "." & document( fv!item.documentId, "extension" ), document: todocument( fv!item.documentId ), showWhen: and( not( rule!APN_isBlank( fv!item.documentId ) ), if( or( document( ri!FICO_documents.documentId[fv!index], "extension" ) = "docx", document( ri!FICO_documents.documentId[fv!index], "extension" ) = "pptx", document( ri!FICO_documents.documentId[fv!index], "extension" ) = "xlsx" ), false, true ) ) ), } ) } ), } ), } ) } ) ) )
Discussion posts and replies are publicly visible
Hello,
The problem is here on the code below.
value: { a!richTextItem( text: rule!FICO_RULE_getImageForDocumentType( document: ri!FICO_documents.documentId[fv!index] ) )
Providing further details on "FICO_RULE_getImageForDocumentType" would be helpful. Anyways the issue is most likely that the documentID from the interface is a temporary reference, so you should not be making reference to it on this step of the interface. You can use the documentId once it has gone through the process model and you have save the document somewhere.