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

Parents
  • 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 Mike Schmitt

    Here's the same code but with the additional code cleanup I mentioned above:

    a!gridTextColumn(
      label: "Date Approved",
      field: "OMCAppointmentInfo.AppointeeOM.DateApproved",
      data: property(property(local!datasubset.data.OMCAppointmentInfo, "AppointeeOM",{}), "DateApproved",{})
    ),
    a!gridTextColumn(
      label: "Date Removed",
      field: "OMCAppointmentInfo.AppointeeOM.DateRemoved",
      data: property(property(local!datasubset.data.OMCAppointmentInfo, "AppointeeOM",{}),  "DateRemoved",{}  )
    ),
    a!gridTextColumn(
      label: "Document 1",
      field: "documentAttachmentArray",
      data: a!forEach(
        items: local!datasubset.data,
        expression: rule!OMC_getDocNames(
          index(
            property(fv!item, "documentAttachmentArray", {})
            1, /* return document array index 1 */
            null()
          )
        ),
      ),
      links: a!forEach(
        items: local!datasubset.data,
        expression: rule!OMC_getDocLinks(
          index(
            property(fv!item, "documentAttachmentArray", {}),
            1, /* get link for 1st document */
            null()
          )
        )
      )
    ),
    a!gridTextColumn(
      label: "Document 2",
      field: "documentAttachmentArray",
      data: a!forEach(
        items: local!datasubset.data,
        expression: 
        rule!OMC_getDocNames(
          index(
            property(fv!item, "documentAttachmentArray", {})
            2, /* return document array index 2 */
            null()
          )
        ),
      ),
      links: a!forEach(
        items: local!datasubset.data,
        expression: rule!OMC_getDocLinks(
          index(
            property(fv!item, "documentAttachmentArray", {}),
            2, /* get link for 1st document */
            null()
          )
        )
      )
    ),
    a!gridTextColumn(
      label: "Appointment Status",
      field: "status",
      data: property(local!datasubset.data,"status",{})
    ),

  • Thanks Mike for the solution. I noted somes issues. For rows with no documents , it still lists docs(possibly from other rows) and no matter what i check (count, nulls etc.,) for , i see this  even though there are no docs. Also, docs displayed are not for the corresponding rows. May be some index is messed up. Any thoughts? 

    Thanks,

    Meena

  • 0
    Certified Lead Developer
    in reply to meenakshir

    Can you share the current state of your code perhaps just for those two columns?  I'm familiar with what causes this -- basically, we would need to make sure the grid receives a "null" for each blank entry, instead of empty set, because when the grid sees an empty set it will try to fill that cell with the next valid value in the array, causing row mismatching.  I can try to provide something that gets around this but would need to work from your latest version.  Just these two columns should be sufficient.

  • Thanks for your help. Here it is. Depending on the stage of the appointment, we have either 0/1/2 docs. 

      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", {})),"; "))
                
                      )   
      ),
      a!gridTextColumn(
                label: "Cover Letter",
                field: "documentAttachmentArray",
                data: if(local!datasubset.totalCount=0,{},a!forEach(items: local!datasubset.data,
                      expression: rule!OMC_getDocNames(index(property(fv!item, "documentAttachmentArray", {}),1,{})))),
                links: a!forEach(items: local!datasubset.data,
                                 expression: rule!OMC_getDocLinks(index(property(fv!item, "documentAttachmentArray", {}),1,{}))
                      )
                     
      ),
      a!gridTextColumn(
                label: "Memo",
                field: "documentAttachmentArray",
                data: if(local!datasubset.totalCount=0,{},a!forEach(items: local!datasubset.data,
                      expression: rule!OMC_getDocNames(index(property(fv!item, "documentAttachmentArray", {}),2,{})))),
                links: a!forEach(items: local!datasubset.data,
                                 expression: rule!OMC_getDocLinks(index(property(fv!item, "documentAttachmentArray", {}),2,{}))
                      )
                     
      )

  • +1
    Certified Lead Developer
    in reply to meenakshir

    A few things:

    1) In my previous example, I made sure the index() calls returned "null" when no data was found, instead of an empty set.  This is important.

    2) I strongly encourage you to not over-compress your code (i.e. removing so many newlines), it makes it nearly impossible to read and make sense of, either as a third party, or in my experience, if i come back some time later even to my own code.

    Please try this version and let me know if it seems to address the link issues.  The intent is that rows without the target document will get a blank label (and link) for that document instead of "stealing" the document from the subsequent row.

    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", {})),"; ")
        )
      )   
    ),
    a!gridTextColumn(
      label: "Cover Letter",
      /*field: "documentAttachmentArray",*/
      data: if(
        local!datasubset.totalCount=0,
        {},
        a!forEach(
          items: local!datasubset.data,
          expression: rule!OMC_getDocNames(
            index(
              property(fv!item, "documentAttachmentArray", {}),
              1,
              null()  /* This needs to be "null" instead of "empty set" to work */
            )
          )
        )
      ),
      links: if(
        local!datasubset.totalCount=0,
        {},
        a!forEach(
          items: local!datasubset.data,
          expression: rule!OMC_getDocLinks(
            index(
              property(fv!item, "documentAttachmentArray", {}),
              1,
              null()  /* This needs to be "null" instead of "empty set" to work */
            )
          )
        )
      )
    ),
    a!gridTextColumn(
      label: "Memo",
      /*field: "documentAttachmentArray",*/
      data: if(
        local!datasubset.totalCount=0,
        {},
        a!forEach(
          items: local!datasubset.data,
          expression: rule!OMC_getDocNames(
            index(
              property(fv!item, "documentAttachmentArray", {}),
              2,
              null()  /* This needs to be "null" instead of "empty set" to work */
            )
          )
        )
      ),
      links: if(
        local!datasubset.totalCount=0,
        {},
        a!forEach(
          items: local!datasubset.data,
          expression: rule!OMC_getDocLinks(
            index(
              property(fv!item, "documentAttachmentArray", {}),
              2,
              null()  /* This needs to be "null" instead of "empty set" to work */
            )
          )
        )
      )
    )

  • 0
    Certified Lead Developer
    in reply to meenakshir

    As a side note, the 19.2+ grid makes this literally 10 times easier.  At least.  I hope you'll let your organization know about all the wasted development time that's occurring at the moment, based solely on their need to use an outdated Appian version.  (I know it's an uphill battle sometimes - i'm just frustrated on your behalf.)

  • Hi Mike,

    I used empty set because i am getting this error. 

    Could not display interface. Please check definition and inputs. Interface Definition: Expression evaluation error at function a!forEach [line 584]: Error in a!forEach() expression during iteration 4: Expression evaluation error in rule 'omc_getdocnames' at function a!forEach: Error in a!forEach() expression during iteration 1: Expression evaluation error at function 'document' [line 2]: Document Does Not Exist or has been Deleted

    here is the rule definition.

    OMC_getDocNames:

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

    OMC_getDocLinks:

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

    Thanks!

  • +1
    Certified Lead Developer
    in reply to meenakshir

    I meant to mention about those earlier - they need to be updated such that they can be run with a single null value and return null instead of breaking.  In our revised code we are (as required) running each rule on one document at a time, passing in either the document id or null(), not an array.  (I believe once passed into the rule, this is cast to an array of 1, either {doc ID} or {null()})

    This modification to getDocNames seems to prevent it breaking when passing in {null()} as the rule input:

    if(
      or(
        isnull( ri!docList ),
        length( ri!docList ) = 0
      ),
      null,
      a!forEach(
        items: ri!docList,
        expression: document(
          fv!item,
          "name"
        )
      )
    )

  • My bad...it works now. Appreciate your timely help. Thanks a lot!

  • 0
    Certified Lead Developer
    in reply to meenakshir

    Great, thanks for confirming - I appreciate you already upvoting my relevant answers.  In addition, if you happen to see the option to click "verify" on any of those, that might help too.

Reply Children
No Data