Skip to main content
marcot0005
Inspiring
Feb 24, 2023 9:44 PM UTC
Question

Check if a document exists in Appian

So I have an interface that has links to documents that have been uploaded. However, the documents don't exist until after they've gone through a process model (or rather they're a temp file that you can't reference at that time). What I'd like to do is disable those links if the documents haven't been put into the system yet, but I am not sure how to check to see if the document exists in the system yet or not. Is there a function or something that can test a doc id to see if it's valid or not?

13 replies

abhayd3663
Brainy
Feb 24, 2023 9:57 PM UTC

findcontentbyattribute(
  searchAllContent: true,
  contentType: "document",
  attributeName: "name",
  searchCriteria: "docName"
)

findcontentbyattribute() is part of Content Tools plug-in, It should be available to most env. please do deploy if not.

marcot0005
Inspiring
Feb 24, 2023 10:18 PM UTC

I need to search by id as the name is not unique

abhayd3663
Brainy
Feb 24, 2023 10:25 PM UTC

getcontentobjectdetailsbyid(id)

Inspiring
Feb 24, 2023 10:11 PM UTC

you can also use the below logic to find the object exist in the system

a!localVariables(
  local!objectDetails: if(
    a!isNullOrEmpty(ri!objectId),
    "No object with this ID has been found",
    getcontentobjectdetailsbyid(ri!objectId)
  ),
  if(
    tostring(local!objectDetails) = "No object with this ID has been found",
    false,
    true
  )
)

marcot0005
Inspiring
Feb 24, 2023 10:17 PM UTC

Thanks, but this gives me true even though I can't download the document yet. It somehow exists, but when I click the link I get a "Error 404 - Page Not Found"

Participating Frequently
Feb 25, 2023 3:35 AM UTC

Hi, Marco

The document must be active published check the below link for more info.

https://community.appian.com/discussions/f/user-interface/25775/error-when-use-function-document

marcot0005
Inspiring
Mar 3, 2023 7:10 PM UTC

Yes I know, the issue was to be able to look at a document ID and tell if it has been published yet or not. getcontentobjectdetailsbyid() allowed me to do that

New Participant
Mar 8, 2023 8:42 AM UTC
[deleted]
davidj137213
Brainy
Feb 23, 2024 1:23 PM UTC

Use getDocumentsFromFolder in the root folder.

harshitb6843
Brainy
Feb 23, 2024 1:55 PM UTC

Its a spam.