not getting downloadLink some times

Hii#All ---not getting downloadLink some times for the Document in a grid
please provide any suggestions on this

Thanks,
Praveen

OriginalPostID-234119


Code.txt

  Discussion posts and replies are publicly visible

  • 0
    Certified Senior Developer
    Can you please share the code?
    I suspect, the apply rule has not been implemented on the link.
  • @praveenkumark Isn't it worth writing rules as follows and reuse them as and when required?


    emobUtilIsValidDocument

    1. documentId_int (Number Integer)

    fn!if(
    \tfn!isnull(ri!documentId_int),
    \tfalse,
    \tfn!isObjectExists("Document",ri!documentId_int)
    \t/* isObjectExists avaliable at http://bit.ly/2coVGoM and safely ignores invalid document objects */
    )


    eumobUiDocumentDownloadLink

    1. documentId (Number Integer)

    fn!if(
    \trule!emobUtilIsValidDocument(documentId_int:ri!documentId_int),
    \ta!documentDownloadLink(label:fn!document(ri!documentId_int,"name"),document:ri!documentId_int),
    \tnull
    )

    And apply in your implementation as follows:

    links: if(rule!APN_isEmpty(data.tAttachmentids),{},apply(rule!eumobUiDocumentDownloadLink,data.tAttachmentids))

    As far as my knowledge is considered, you shouldn't remove the nulls and apply documentDownloadLink function. Let the nulls or invalid document ids be present in the actual data(provide to 'links attribute') similar to the nulls or invalid document ids present in the actual data in the 'data' attribute. Apply a!documentDownloadLink only on those elements that evaluate to proper document objects and don't apply it when the check evaluates to false. This way, you can make sure that the number of links is equal to the number of elements in data and can eliminate the mismatch between the both. Also, you can safely avoid invalid document objects(where document id is in the database but the actual document object is deleted), nulls and array handling which might cause errors at times.
  • 0
    Certified Senior Developer
    @praveen if you keep a!documentDownloadLink(_) in a rule and call it from apply loop.. I was faced same issue when I am new to appian but the solution what was given above solved my problem ..