Locate an specific subfolder and delete the documents included in it and delete this subfolder

Certified Associate Developer

I have being seeking information about my problem but I haven't found the properly anwser. I have a constant as you see:

I'm creating dinamic subfolders inside this folder. Inside them I'm going to create documents. In some situations I will need to delete the documents in a particular subfolder and delete the subfolder as well. I have cheked the documentation (delete folder smart service, delete document smart service) but I don't know how to use it because I need to provide a folder type in the Input variable and I haven't this type of data. I have a variable with the name of the subfolder that is dinamically generated (for instance, today's date) and I need to use this name to delete the subfolder as well. Is there any way to do so?

Thanks in advance!

  Discussion posts and replies are publicly visible

Parents
  • 0
    Certified Lead Developer

    Appian identifies folder by a numeric ID. When creating folders, I highly recommend to store that ID somewhere in a record. This makes any deletion operations very simple.

    If you maintain an existing folder, and someone else made such decisions in the past, the plugin "Content Tools" with the function "findcontentbyattribute" can find folders by name.

  • 0
    Certified Lead Developer
    in reply to Stefan Helzle

    Here's an example of how you can use findcontentbyattribute to find folders. But I agree with Stefan, much better to store in the database if you can.

    a!localVariables(
      local!nameToSearchFor: "Artifacts",
      local!results: findcontentbyattribute(
        searchAllContent: true,
        contentType: "folder",
        attributeName: "name",
        searchCriteria: concat("*", local!nameToSearchFor, "*")
      ),
      a!forEach(
        items: local!results,
        expression: a!map(
          id: folder(fv!item, "id"),
          name: folder(fv!item, "name")
        )
      )
    )

Reply
  • 0
    Certified Lead Developer
    in reply to Stefan Helzle

    Here's an example of how you can use findcontentbyattribute to find folders. But I agree with Stefan, much better to store in the database if you can.

    a!localVariables(
      local!nameToSearchFor: "Artifacts",
      local!results: findcontentbyattribute(
        searchAllContent: true,
        contentType: "folder",
        attributeName: "name",
        searchCriteria: concat("*", local!nameToSearchFor, "*")
      ),
      a!forEach(
        items: local!results,
        expression: a!map(
          id: folder(fv!item, "id"),
          name: folder(fv!item, "name")
        )
      )
    )

Children
No Data