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

Parents
  • 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.

Reply
  • 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.

Children
No Data