Saving pdf id to table.

We are trying to understand how to upload a pdf into a folder and save the id in table to be retrieved later. We are not able to get the id to return and then save it.  We have a response json and we can't just hardcode from the uploadfield.  in the component containing the upload field  we can't call from the process model that component.  All the interfaces are nested and dynamic and contained in a dynamic json.  Currently, attempting to create a process model for uploading the pdf has failed because we can't get the id back when the pdf is being stored in a folder. 

  Discussion posts and replies are publicly visible

  • I'm a little fuzzy on your use case, but if you are trying to get the ID of a document from a!fileUploadField() where it is being selected on an interface, the form will need to be submitted to turn it into a document object before you can retrieve the ID, then you can use =document(pv!document,"id") in a script task, etc.

    A common solution is to add a button which submits the form (this creating the document object), and chains back to itself, giving the user the impression that they never left the form.

    Otherwise, please share a little more details on your use case, code, things you have tried etc.

  • 0
    Certified Senior Developer

    You can use FileUploadField component to upload the file and use a ruleInput variable which will handle your document id. Once you upload the document there will a button which will help you to submit the form and on saveinto of that button you can use writetodatastoreEntity and save the id into Db and use that id in future to get the document for the particular id. For more details, I am attaching the code below.

    On click of submit button, The highlighted ID will store into DB and by using this ID you can fetch the document as well.

    {
      a!fileUploadField(
        label: "Upload Document",
        target: tofolder(25436),/*use your folder id*/
        value: ri!documentID,
        saveInto: ri!documentID
      ),
      a!buttonLayout(
        primaryButtons: {
          a!buttonWidget(
            label: "Submit",
            submit: true(),
            saveInto: {
            /*Change the below function according to your requirement*/
              a!writeToDataStoreEntity(
                dataStoreEntity: cons!UAS_DSE,
                valueToStore: 'type!{urn:com:appian:types:UAC}UAC_UAS_Onboard_Data'(assettype: ri!documentID)
              )
            }
          )
        }
      )
    }

    Note: It will work only on process start form or user input task. File upload field will not work any other places.