Need to get a document or doc ID by UUID or document name

Hi All,

I have a requirement where I need to get a document or document ID by UUID (ideal option), or worse case by document name.  I know this is not possible out of the box.  I have read that there used to be functions in shared components that could accomplish this.  With shared components being deprecated, what plugin could I use for this use case?

Thanks,

Walker

  Discussion posts and replies are publicly visible

Parents Reply Children
  • Danny, that is a good point.  The reason is that while the client is imagining a future state where the user will have the ability to add images to be used dynamically on forms at some point, my team is in a position where we will need to maintain a list of these images manually for some time before the user has the ability to upload themselves. It would make that easier to manage if we could set it up for one environment, and not have to change the IDs in the DB when deploying.

    If I was to use doc id, what is the best way to retrieve the document id for a newly uploaded document?  I know I have to submit the form first, and retrieve it after submission, but I am not sure how to retrieve it the newly uploaded document.

    Thanks again

  • Have you considered adding some kind of "Admin" page that would allow you to manage the images manually at the beginning? That's often what I've seen in cases like this because you then wouldn't have to do a deployment. Also, I'm not sure how often you expect to need to change these documents, but it will be a lot easier to manage them directly from the production UI rather than doing a deployment each time.

    Like Danny said, I'd recommend avoiding the use of UUID for documents if possible. Granted it would probably work fine, but just seems unecessary.

  • Thanks Peter, that is what I will be doing eventually (described in my previous comment). I think I will just have to move it up the priority list.  

    If I was to use doc id, what is the best way to retrieve the document id for a newly uploaded document?  I know I have to submit the form first, and retrieve it after submission, but I am not sure how to retrieve it the newly uploaded document.

  • Great question! On your form, have a rule input of type document which you'll use as the value and saveInto field for your file upload. Then, in the process model have a corresponding process variable of type document to map to your form rule input. You can then use this process variable to get the document ID by doing document(pv!myDoc,"id")

  • This works consistently only if you introduced a delay after the submit action before accessing the documents.  Otherwise you get this error -  

    a!forEach: Error in a!forEach() expression during iteration 1: Expression evaluation error at function 'document' [line 4]: Document Does Not Exist or has been Deleted) (Data Outputs).

    The delay of 1 minute gives Appian enough time to finish the uploading of the files internally to the correct folder before you can access the files' attributes. 

    NOTE - I have also noticed that documents couldn't be accessed in the same process model that is called in the submit action of the file upload form if activity chaining is enabled in the process model.  The behavior was random.  I have disabled activity chaining in my PM just to avoid surprises.