Retrieving a specific document in PM based on its name

Certified Senior Developer

Hi all,

I'm a bit unfamiliar on how can I search for a document based on its name to send it on an email? right now of course doing it manually works but I was wondering if there is a function that returns the document based on its name or anything similar.

For example, I want to send the document named YI5688 (saved in my appian folder called documents) , my process variable contains the name , but I'm not sure how to "search" for the document. Any thoughts or suggestions?

Thanks in advance!

  Discussion posts and replies are publicly visible

Parents
  • 0
    Certified Lead Developer

    You can use the Content Tools plug-in and its built-in functions like "find content by attribute" which allows you to supply criteria to search such as the name, root folder, type (in this case "document").  Note that Appian has no requirement that files in any folder have unique names, so you will always need to take further steps to ensure you're pulling back only one result.  Generally if you're trying to reference a static file within a process, though, it is recommended to create a constant that points to that file, then reference the constant in your process.  I don't know enough about your use case in this situation to really say much either way about it.

  • 0
    Certified Senior Developer
    in reply to Mike Schmitt

    I see, thank you for your response! in terms of my use case is more of each record of a table has a document that belongs to it, it needs to be sent when the user performs a record action, so I was looking for a way to pull that specific document from the folder depending on the name since in my table I have the name saved. so basically for example my record type is employee and the documentname is a field in this table. I can easily reference the name based on the selected record.

  • 0
    Certified Lead Developer
    in reply to Maria

    You should definitely be saving the document ID in your database table, not the filename.

  • 0
    Certified Senior Developer
    in reply to Mike Schmitt

    In that case, if I save the documentId to my database table. I could use the todocument function to retrieve the document in my process model correct?

  • 0
    Certified Lead Developer
    in reply to Maria

    You don't even need todocument - the "document" object type is just a wrapper for the document ID (which is just an integer) - you can freely typecast from one to the other.  So if you look up your document ID from the DB (by any of a hundred different standard methods), you can just save it into a PV of type "document" and use that for whatever you'd want.  (It could even be a PV of type integer instead, though in your process instance you'd just see the ID instead of the document name etc.)

Reply
  • 0
    Certified Lead Developer
    in reply to Maria

    You don't even need todocument - the "document" object type is just a wrapper for the document ID (which is just an integer) - you can freely typecast from one to the other.  So if you look up your document ID from the DB (by any of a hundred different standard methods), you can just save it into a PV of type "document" and use that for whatever you'd want.  (It could even be a PV of type integer instead, though in your process instance you'd just see the ID instead of the document name etc.)

Children
No Data