a!gridLayout( label:"", headerCells:{ a!gridLayoutHeaderCell(label:"Upload"), a!gridLayoutHeaderCell(label:"DocDescription"), a!gridLayoutHeaderCell(label:" ") }, columnConfigs:{}, rows:{ a!forEach( items:{ if( ri!isReadOnly, ri!Document, if(rule!FCO_isNullOrBlank(ri!Document), null(), ri!Document[wherecontains(local!mappingId,ri!Document.mappingKey)] )),}, expression:a!gridRowLayout( contents:{ a!fileUploadField( label:"Upload Document", target:cons!SHA_FOLDER, maxSelections:1, value:index(local!Doc,"appianDocId",null), saveInto:fv!item.appianDocId, required: true(), requiredMessage:"Please upload document", disabled:ri!isReadOnly ), a!textField( label:"docdescription", placeholder:"enter doc description", value:index(local!Doc,"docDescription",null), saveInto:fv!item.docDescription, required: true(), readOnly:ri!isReadOnly ), a!richTextDisplayField( labelPosition: "", value: { a!richTextIcon( icon:"trash-o", link: a!dynamicLink( value:fv!index, saveInto:a!save(ri!Document,remove(ri!Document,fv!index)) ), color:"NEGATIVE", size:"STANDARD" ) } ) } ) ) }, selectionValue:ri!Document, selectionSaveInto:ri!Document, selectable: {}, selectionRequired:false, selectionDisabled:{}, addRowLink:a!dynamicLink( label: "Upload New File", value:true(), saveInto:{ a!save( ri!Document, append( ri!Document, a!forEach( index(reverse({save!value}),1), 'type!{urn:com:appian:types:SHA}SHA_document'( mappingKey: local!mappingId )))), local!Doc } ), validations: {}, shadeAlternateRows:true )
Discussion posts and replies are publicly visible
Following the error message, the saveInto in line 29 should be more like
fv!item.appianDocId.documentId
When I tried I am facing the index error.
Actually here appianDocId is the field where I save the uploaded documents
Is the field appianDocId a CDT type or an integer? Is it multiple?
yes the appianDocId is an integer field in a document CDT and yes its is multiple
OK. So your ri!document is a multiple of SHA_document. Inside SHA_document is a single integer field called documentId.
That should work in general. Looking a bit deeper in your code, I see some potential issues.
For the value parameter you use a local variable, while for the saveInto your use fv!item.
The addRowLink looks pretty complicated. What is that forEach() doing?
Line 11 looks like
{ if( ri!isReadOnly, ri!Document, if(rule!FCO_isNullOrBlank(ri!Document), null(), ri!Document[wherecontains(local!mappingId,ri!Document.mappingKey)] )),},
What are the enclosing curly brackets doing? This might lead to a data structure that is a list containing a list of documents. Then fv!item is not a document, but rather a list of documents.
Here actually I have a list and I have an option to add multiple lists. So for example, if i have list 1 and i upload 2 documents in it and i have list 2 and i upload 3 documents in it should show me like
List 1 - Document 1
List 1- Document 2
List 2 - Document 1
List 2 - Document 2
List 2 - Document 3
So when i trying to add a new list the documents in the previous list are generated. So that is why I used foreach to generate new (multiple) upload file fields for each different list .(Actually, i used transient value in my CDT .)
In your code, I do not see any multiple lists ...
This feels like a rather complicated design and you being stuck.
I suggest to try to simplify it, ensure your data structures fit the purpose and also check the other hints I made.
Yeah sure will try to simplify it. Thank you for your time and suggestions