How to check if folder already exists from process model?

Hi guys,

I've got a process model that creates a folder and generates a text document that it then stores in this folder. Our application uses workflows, and the folders will be created with the workflow ID.

However, this process model may be run several times for a workflow, and it would then try and generate a folder with the same name each time. Does Appian throw an error if the smart service tries to create another folder with a name that already exists? If it does, is there a way to check if it exists first and either update this existing folder instead or create a new one with a different name as required?

Thanks.

  Discussion posts and replies are publicly visible

Parents
  • +1
    Certified Lead Developer

    There's no requirement that folders have a unique name - though I'd warn against creating too many folders with identical names as it could make troubleshooting a nightmare.

    More to your point - off the top of my head I don't remember any direct way to find a folder by name.  A workaround I've used in the past is using a plug-in function like "get subfolders from folder" to return all children of a parent folder, then using a!forEach to iterate through them and see if any have a matching folder name.  Before doing this though, I think a much stronger solution would be to store the initial created folder ID to the database somewhere that it could be traced to your workflow ID, and just query for that workflow ID before attempting to create a new folder in any new process instances.

  • One thing I have often done is to store the folder ID as a field in your CDT - in this case, you could associate your folder ID with a given workflow in the database. Then, you can use the workflow ID to find the associated folder ID. If there's already an existing folder, you don't have to create a new one and can store your documents directly in that folder. If there isn't an existing ID, that's when you can create one.

Reply Children