Document upload field

Interface Definition: Expression evaluation error [evaluation ID = af95d:a8823] : An error occurred while executing a save: Expression evaluation error: The save target must be a local variable that does not refresh on every evaluation or on an interval, a process variable, or a node input (or a rule input passed one of those three), but instead was: [documentId=, mappingKey=1, entityType=, entityId=, docType=, docName=, docExtension=, docDescription=, appianDocId=, isActive=, createdBy=, createdDate=, lastUpdatedBy=, lastUpdatedDate=].
In my interface, I can add multiple lists and in each list, I have multiple documents. This is my requirement. 
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
                        )
So when I am trying to upload a document I am unable to save it it throws me the above error! 
Can anyone please help me with this error!

  Discussion posts and replies are publicly visible

Parents Reply Children
  • 0
    Certified Lead Developer
    in reply to gaddamv0001

    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 .)

  • 0
    Certified Lead Developer
    in reply to gaddamv0001

    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