How to display multiple files with document link in a single column

Hi,

I have a grid style interface based on process backed record. One of the column(Documents) has multiple files. See the screenshot below:

I'm trying to display download link for the docs listed. I am getting error "Could not display interface. Please check definition and inputs.
Interface Definition: Expression evaluation error at function a!forEach [line 358]: Error in a!forEach() expression during iteration 1: Expression evaluation error at function 'document' [line 361]: The passed parameter(s) are of the wrong type. Received the type List of Document."

Here is the code:

a!gridTextColumn(
            label: "Documents",
            field: "documentAttachmentArray",
            data: if(local!datasubset.totalCount=0,{},a!forEach(items: local!datasubset.data,
                  expression: joinarray(index(fv!item, "documentAttachmentArray", {}),"; "))),
            links: a!forEach(
                   items: local!datasubset.data,
                   expression: joinarray(a!documentDownloadLink(
                              label: document(index(fv!item, "documentAttachmentArray", {}),"name"),
                              document: index(fv!item, "documentAttachmentArray", {})
                ),"; ")
                   )
          )

Any help is appreciated.

Thanks,

Meena

  Discussion posts and replies are publicly visible

  • 0
    Certified Lead Developer

    Hi Meena,

    If you are using 19.2 version or above, you can use below snippet,

    136627,136626

    {
    a!sectionLayout(
    contents: {
    a!gridField(
    label: "Read-only Grid",
    labelPosition: "ABOVE",
    /* Any data with type data subset, cdt or dictornary can be used*/
    data: {
    documentId: {
    136627,
    136626
    }
    },
    columns: {
    a!gridColumn(
    label: "Documents",
    value: a!richTextDisplayField(
    value: a!forEach(
    {
    136627,
    136626
    },
    {
    a!richTextItem(
    text: document(
    fv!item,
    "name"
    ) & char(
    10
    ),
    link: a!documentDownloadLink(
    document: fv!item
    )
    )
    }
    )
    )
    )
    },
    validations: {}
    )
    }
    )
    }

    ----------------------------------------
    If your Appian version is less than that, then you can editable grid and use a!richtextdisplayfield and have all the rows read-only.

    Thanks

    Subha

  • 0
    Certified Lead Developer

    Can you confirm what version of Appian you're on?  Hopefully it's 19.2+ as subhad previously mentioned as it would be a very preferable option for you to convert your grid to the 19.2 version (your current code is still using the old a!gridTextColumn() rule which goes with the older style grid, so either way some conversion would be necessary).

  • 0
    Certified Lead Developer
    in reply to meenakshir

    I think your only choice might be, like Subhad also mentioned already, to use an Editable Grid - in the old style paging grid, there isn't any way that I know of to have multiple links in a single given cell in a paging grid, due to the way the configuration works.

    Out of curiosity, is upgrading to 19.2+ on your roadmap at all?  18.2 is missing many newer features which I would consider essential at this point.

  • Thanks Mike. Yes, we'll upgrade in 3rd quarter but this is for the current release.

  • 0
    Certified Lead Developer
    in reply to meenakshir

    Alternatively I'd suggest maybe not worrying about showing the documents / links in the record list grid like you have here - i assume you're allowing a user to link to that record, so why not just show a downloadable list of documents once they're on the interface for a particular record?  I'd suggest that having downloadable documents at the top level like you're trying to do adds unnecessary clutter to the already dense grid, though with that said I have no way of knowing what your customer requirements are.  If you are required to show those documents and you can't go with an editable grid, then you could perhaps show just the plain names of the documents instead of their IDs.

  • Customer requirement is to show the documents with links so they would be able to download. This will have only a max of two documents. I was able to list the names in the paging grid but struggling to list the download links with it.  It always shows the link for the very first document even though the rule OMC_getDocLinks return mulitple.

    OMC_getDocLinks Rule: 

    if(isnull(ri!docList),null,a!forEach(items:ri!docList,
    expression: a!documentDownloadLink(label:document(fv!item, "name"),
    document:fv!item))
    )

    Rule Output:

    List of DocumentDownloadLink: 2 items DocumentDownloadLink document: 9535 - OM Cover Letter.pdf (Document) label: "OM Cover Letter" actions: null (List of Variant) version: -1 DocumentDownloadLink document: 9536 - OM Memo.pdf (Document) label: "OM Memo" actions: null (List of Variant) version: -1

    a!gridTextColumn(
                label: "Documents",
                field: "documentAttachmentArray",
                data: if(local!datasubset.totalCount=0,{},a!forEach(items: local!datasubset.data,
                      expression: joinarray(rule!OMC_getDocNames(index(fv!item, "documentAttachmentArray", {})),"; "))),
                links: a!forEach( 
                       items: local!datasubset.data,
                      expression: rule!OMC_getDocLinks(index(fv!item, "documentAttachmentArray", {}))
                      )
                 )

  • 0
    Certified Lead Developer
    in reply to meenakshir

    Yeah - as I mentioned above, you can add a max of 1 link per cell in the old style paging grid.  Your options are pretty much limited to upgrading to 19.2+ and using the updated grid, or perhaps as a workaround for now, you could add a second column and just show one document in each column (and just don't show any content in the second column when it's not indicated).

  • You may want to think creatively about this too - could you click on the link to display the documents below the grid using the document viewer component? Or is there a reason they have to download the documents individually? Could you have the link send them an email with the documents or download a zip file with both of them together?

    If you need it to behave exactly as stated, an editable grid would work, but it seems like there are other methods that might work just as well.

  • Thanks for your suggestions. Tried to use document viewer component but looks like it is not available in 18.2.  Also, we are trying to modernize the application which is portal based and users are used of all these behaviors for years and any change is very tough to get support. But we are constantly trying. They already get docs in email but these are part of customized process dashboard where they get summary and also access to docs which is convenient for Contracting officers since they deal with several contracts and don't want to look through their email unless they are working on a particular one.

    What other methods other than editable grid work in 18.2?

    Thanks,

    Meena