Documents shown on documentdownload link

Hi All, 

    i have written a work for export to excel and with download functionality, 

   in download document link , all the document in an array is show, how can i show documents with specific keyword in document name,

    like , if the array has 10 documents, i want to show documents link which names contains ABCD,

   i have attached the code, please help.

a!localVariables(
  local!test : null,
  local!EligiblePoolProcessInfo,
  local!EligiblePoolExportedData,
  local!errorMessage,
  /* Fetch documents respective to program ids*/
  local!eligiblePoolDocs:  a!refreshVariable(
    value:finddocumentsbyname(
      searchAllContent:true,
      documentNameToSearchFor:ri!programId&"_"&text(now(), "DDMMYYYY")
    ),
    refreshAlways: true
  ),
  local!eligiblePoolDocDeriveNames: 
  a!refreshVariable(
    value:if(rule!APN_isBlank(local!eligiblePoolDocs),{},
    tointeger(stripwith(stripwith(touniformstring(local!eligiblePoolDocs),"[Document:"),"]"))),
    refreshAlways: true
  ),
  local!eligiblePoolDocNames:  
  a!refreshVariable(
    value:if(rule!APN_isBlank(local!eligiblePoolDocDeriveNames),{},
    substitute(
      a!forEach(
        items: local!eligiblePoolDocDeriveNames,
        expression: document(fv!item,"name")),ri!programID,"EP")
    ),
    refreshAlways: true
  ),
  {
      a!linkField(
        labelPosition: "COLLAPSED",
        links:a!dynamicLink(
          label:"Export to Excel",
          saveInto: {
            a!startProcess(
              processModel:cons!CMP_EXP_EligiblePoolPM,
              processParameters: {
                groupType : ri!groupType,
                progarmId : ri!programId,
                clsSbg: ri!sbg
              },
              onSuccess: {
                a!save(local!EligiblePoolProcessInfo,fv!processInfo),
                a!save(
                  local!EligiblePoolExportedData,
                  index(
                    local!EligiblePoolProcessInfo.pv,
                    "output_document",
                    {}
                  )
                )
              },
              onError: a!save(
                local!errorMessage,
                "Error Exporting File to Excel"
              )
            )
          }
        ),
        showWhen: and(isnull(local!EligiblePoolExportedData),
        ),
        align: "RIGHT"
      ),
      /*a!linkField(*/
        /*showWhen: not(isnull(local!EligiblePoolExportedData)),*/
        /*align: "RIGHT",*/
        /*links: */
        /*{*/
          /*a!documentDownloadLink(*/
            /*label: "Download Excel File",*/
            /*document: local!EligiblePoolExportedData*/
          /*)*/
/*    */
        /*}*/
      /*)*/
      a!richTextDisplayField(
        align: "RIGHT",
        value: a!richTextItem(
          text: "*Document will be available shortly after clicking.",
          style: "EMPHASIS",
          color: "SECONDARY",
          /*showWhen: not(local!IsProcessCompleted)*/
        )
      ),
      a!richTextDisplayField(
        align: "RIGHT",
        value: a!forEach(
          items: local!eligiblePoolDocNames,
          expression:  a!richTextItem(
            text:fv!item&"  ",
            link:  a!documentDownloadLink(

              document: index(local!eligiblePoolDocs,fv!index,fv!index)
            )

          )
        ),
      )
  }
)

   Thanks in advance

  Discussion posts and replies are publicly visible

Parents Reply
  • 0
    Certified Lead Developer
    in reply to vineethk0001

    Isn't your local!eligiblePoolDocNames variable handling that?  Or does it currently contain all documents?  It seems like that would be a good place to do this filtering, though I'm not super clear on the intent behind all the other processing happening in your local variable definitions.

    Assuming that variable does contain all docs and needs to continue doing so, then i suppose you can try something like this:

    a!forEach(
      items: local!eligiblePoolDocNames,
      expression: if(
        search("ABCD", fv!item) = 0,
        {},
        a!richTextItem(
          text:fv!item&"  ",
          link:  a!documentDownloadLink(
            document: index(local!eligiblePoolDocs, fv!index)
          )
        )
      )
    )

Children