how to find all documents belong to certain folder?

I am trying to delete a folder's all documents, at interface expression mode, how to write the code and how to express the document name at a!deleteDocument(document:??????).

Thanks

  Discussion posts and replies are publicly visible

Parents
  • 0
    Certified Lead Developer

    As a!deleteDocument can only delete a single document, you will need to create a process to delete multiple documents.

    Documents in Appian are referenced by their ID either in a variable of type Integer or of type Document.

  • a!localVariables(
      local!oldfile: a!refreshVariable(folder(31338, "documentChildren")),
      local!file: a!refreshVariable(folder(31338, "documentChildren")),
      local!deletefile,
      local!oldfilelist,
      local!testfile:rule!testfilecasttype(),
      {
        a!fileUploadField(
          label: "File Upload",
          labelPosition: "ABOVE",
          target: cons!fileUploadConstant,
          maxSelections: 10,
          value: local!file,
          saveInto: {
            a!save(
              target: local!oldfile,
              value: folder(31338, "documentChildren")
            ),
            /*if(length(local!oldfile)=0,{},a!deleteDocument(document:local!oldfile)),
            */
            a!save(target: local!file, value: save!value),
            a!save(target:local!oldfilelist,value:a!forEach(items:local!oldfile,
            expression:tostring(fv!item)
            /*extract(left(fv!item,20),":","]"),*/
            )),
            a!save(
              target: local!deletefile,
              value: a!forEach(
                items: local!oldfile,
                expression: if(
                  contains(local!file, fv!item) = true(),
                  {},
                  fv!item
                ),
              )
            ),
            a!save(target:local!testfile.file,value:local!oldfilelist),
            a!save(
              target: ri!file.file,
              value: a!forEach(items: local!file, expression: fv!item, )
            ),
            
          },
          fileNames: { fv!file.name },
          validations: {},
          uploadMethods: "CHOOSE_FILE"
        ),
        a!buttonArrayLayout(
          buttons: {
            a!buttonWidget(
              label: "Submit",
              style: "PRIMARY",
              submit: true(),
              loadingIndicator: true(),
              saveInto:{
                /*if(*/
                  /*or(*/
                    /*length(a!flatten(local!deletefile)) = 0,*/
                    /*len(local!deletefile) = 0*/
                  /*),*/
                  /*{},*/
                  /*a!deleteDocument(document: local!deletefile)*/
                /*),*/
                /*a!writeToMultipleDataStoreEntities(*/
                /*valuesToStore: {*/
                /*a!entityData(entity: cons!testfileconstant,data:local!testfile),*/
                /*}*/
                /*),*/
                a!startProcess(
                  processModel: cons!wangtestfileuploadprocessmodel,
                  processParameters: {
                    deletefile:local!deletefile,
                    testfile:local!testfile,
                    
                  }
                ),
              }
              
            )
          },
          align: "START"
        ),
        a!milestoneField(
          label:"phase",
          labelPosition: "ABOVE",
          steps: cons!wangtestphase,
          links: {},
          active: 2,
        )
      }
    )

  • local!deletefile shows are multiple, but once get into processModel it changes to be single always, though i set property values and others to multiple

  • 0
    Certified Lead Developer
    in reply to immortalvirgil

    Did you set the process variable deletefile to be a multiple in the model?

  • The first as original one can't set to be multiple, so i create a new one at second set it to multiple but not works

  • 0
    Certified Lead Developer
    in reply to immortalvirgil

    You cannot just add inputs and expect this to work!!!

    This node can only delete a single file. To delete multiple you need to execute the node multiple times.

Reply Children