Can I save a document to a CDT?

Certified Lead Developer

We have a multiple CDT.
A couple of the fields in the CDT are of type Document.
When in a form, the user uploads a document via fileUploadField and the document is saved to the appropriate field of type document in the CDT.
Back in process the CDT is passed from the ri in the form to the ac in the user input node, and the ac is saved to the pv for that CDT.
But when the user submits the form and the CDT is saved to the db, the appian doc id is wrong (usually off by 1) and the document is lost.

Why can't I save a document to a CDT?

OriginalPostID-211221

OriginalPostID-211221

  Discussion posts and replies are publicly visible

  • 0
    Certified Lead Developer
    Until the form submission, the document is saved on the server with an inactive temporary Id and we cannot perform any operations with that Id. Once the form is submitted, the document is saved with a new version
  • As specified in the post above, to resolve this issue add another rule input of type document and in the back end save that into a process variable of document type and later map it to the CDT document type field. This will ensure that the actual document ID is stored in the CDT.
  • 0
    Certified Lead Developer
    Is this an issue that Appian is slated to work on anytime soon? This has caused us some serious headaches as the solution isn't at all obvious or intuitive.

    Will try the solution mentioned above.
  • 0
    Certified Lead Developer
    Charles you can raise a support ticket with Appian but you can refer to the first post from Eduardo Fuentes on the bellow entry, does not looks like it has been taken care so far.
    forum.appian.com/.../e-141769
  • I think this has been a behaviour/limitation of appian since I have started practising appian.
    When you upload a document in the form it is stored temporarily in the server and a temporary document id is created. When you submit the form it is stored in the targeted KC and document id is incremented.
    I would like to correct something in your post, there cannot be fields in a CDT which are of type Document.
    But I think you intend that there are some field that are of type integer and store the document id.

    For achieving your requirement there are some ways which i would like to share.
    You can have a buttonWidgetSubmit with name "Upload" and style "NORMAL" which upon clicking submits the form, goes into the process model (which helps the document getting upload into the targeted KC) and then comes back to the same form immediately through activity chaining.
    There should be a XOR gate which should check that the submit action was from the Upload button not from actual submit button.
    After the XOR check there should be a script task by which you can initialize the document id cdt field with the actual document id.
    Now as you have the actual document id you can convert it into a document and perform a variety of validations.

    Attaching some screenshot for your information.
    Hope the information was helpful.

    Upload Doc Form and process model.zip

  • @Charles.We have faced the same issue some time back.
    As an alternate solution, Instead of storing document directly in the cdt, store it in a process variable of type document and then in the process store the document in cdt from process variable.