How to configure default document

Hi,

my requirement is to set the default document so i have taken value from my database which i have already uploaded and i used those values into the linkfield with  a!documentDownloadLink but still i unable to see the document can you please help me where i went wrong, Below is my code.

a!localVariables(
local!text:"Please refer these document and send your reply soon",
local!newGrid:'type!{urn:com:appian:types:SHA}SHA_receivedDocuments'(),
local!emailSubject:"Sending mail regarding Property Documents",
local!document:40915,
local!docName:"Dummy Document",
{

a!sectionLayout(
          label:"",
          contents: {
            a!richTextDisplayField(
              labelPosition:"COLLAPSED",
              value:{
                a!richTextIcon(
                  icon:"file-text",
                  color:"ACCENT",
                  size:"LARGE" 
                ),
                a!richTextItem(
                  text:"Document",
                  color:"SECONDARY",
                  size:"LARGE",
                  style:"STRONG"
                )
              }
            )
          },
          divider:"BELOW"
        ),
a!gridLayout(
           headerCells: {

            a!gridLayoutHeaderCell(label:"Upload Document",align:"CENTER"),
            a!gridLayoutHeaderCell(label:"Document Type",align: "CENTER"),
            a!gridLayoutHeaderCell(label:"Document Description ",align: "CENTER"),
            a!gridLayoutHeaderCell(label:"Action")
          },
          columnConfigs: {

            a!gridLayoutColumnConfig(width: "DISTRIBUTE"),
            a!gridLayoutColumnConfig(width: "DISTRIBUTE"),
            a!gridLayoutColumnConfig(width: "DISTRIBUTE"),
            a!gridLayoutColumnConfig(width: "ICON" )
          },
          rows:{
            a!forEach(
              items: ri!documents,
              expression: a!gridRowLayout(
                contents: {
                 if(
                   rule!FCO_hasValue(fv!item.receiveDocId),
                  a!fileUploadField(
                    label: "File Upload",
                    labelPosition: "ABOVE",
                    target:cons!SHA_FOLDER,
                    maxSelections:1,
                    value:fv!item.receiveDocId,
                     
                      
                    saveInto: fv!item.receiveDocId,
                    required: true(),
                 
                  ),
                  a!linkField(
                    links: {
                      a!documentDownloadLink(
                        label: local!docName,
                        document:todocument(local!document)
                      )
                    }
                  ),
                  ),
                  a!dropdownField(
                    label: "Document Type",
                    labelPosition: "ADJACENT",
                    placeholder: "Select the type of document",
                    choiceLabels:cons!SHA_TYPESOFDOCUMENTS,
                    choiceValues:cons!SHA_TYPESOFDOCUMENTS,
                    value:fv!item.docType,
                    saveInto:fv!item.docType,

                  ),

                  a!textField(
                    label:"Document Description",
                    placeholder:"Enter document description",
                    value:fv!item.docDescription,
                    saveInto:fv!item.docDescription,


                  ),
                  a!richTextDisplayField(
                    label: "Rich Text",
                    labelPosition: "COLLAPSED",
                    value: {a!richTextIcon(
                      icon: "trash",
                      link: a!dynamicLink(
                        saveInto: a!save(ri!documents,remove(ri!documents,fv!index)
                        )
                      ),
                      size: "STANDARD",  
                      color:"NEGATIVE",

                    )},


                  )

                }

              )
            ),


          },
          selectionValue: ri!documents,
          selectionSaveInto: ri!documents,
          addRowLink: a!dynamicLink(
            label: "Upload file",
            value:true(),
            saveInto:{ a!save
            (ri!documents,append(ri!documents,{local!newGrid}))
            } ,


          ),


        ),

   }   
   )

  Discussion posts and replies are publicly visible

Parents
  • 0
    Certified Lead Developer

    I also don't see any obvious errors in your code - though I'm a little confused as to what you hope to accomplish in showing the DummyDocument.  When the "receiveDocId" is empty you're showing the Dummy Document as a download link... but this would prevent the user from ever seeing the file upload field and providing an uploaded copy.  Which begs the question: why even bother have the upload field, if it'll never actually be shown?

  • Yeah this is a really good point. Plus keep in mind that you could end up with pretty weird behavior if you cleared an existing document (when the file upload field is shown), because then you would never be able to get back to the upload view.

    Can you talk a bit more about what your use case / application is?

  • thank you peter for your reply, my application is property management,I am sending a mail to the  buyer with the signed documents (which is default document, default body ),sending mail is related action, upon clicking this action the inteface will be open with all these default docs and body if they want they can uploaad the document and change the body while sending the email

  • But how will they upload any documents?? When you add a new row it will display the default document and there will be no way to get it to show the file upload. I'd suggest rethinking your grid - you might be able to do something like provide a checkbox to "use default document" that would then hide the file upload field, but as it stands it will always show the link and never show the file upload (because the value would always be null when you add a new row).

Reply
  • But how will they upload any documents?? When you add a new row it will display the default document and there will be no way to get it to show the file upload. I'd suggest rethinking your grid - you might be able to do something like provide a checkbox to "use default document" that would then hide the file upload field, but as it stands it will always show the link and never show the file upload (because the value would always be null when you add a new row).

Children
No Data