What is the best practice to save mutiple cdt at the same time?

I am creating a form where the User can attach files, I have created a section which included input fields and upload document fields. The user should have option to add multiple files with the metadata. 

(when the user clicks on add more files, then It should open up another section with all the fields)

I know I can use loop in the process model but is there any other best way to do it?

  Discussion posts and replies are publicly visible

  • 0
    Certified Lead Developer

    I would create a reference table that stores the foreign key of the parent CDT along with the ID of one document.  You would then create a new sub CDT with that structure.  Part of whatever CDT you're now using should be a list of type newDocumentCDT (or whatever you call it).

    You can then save the list with a write to datastore node, or even save the whole structure at once.  I believe Appian can handle properly saving the individual nodes of an Array member of a CDT while it saves that CDT.  If you just save the list, just click the "Multiple" checkbox.  If the input is a single value, it saves a single row.  If it's a list, it automatically saves multiple rows.

  • 0
    Certified Lead Developer

    I agree with all the stuff David said previously, but to answer your question, looping in a process model is probably the only really good way to handle documents.  When uploading documents from an interface it's critical to actually submit the form in order for the document to be transferred to its target folder instead of the unusable system folder Appian keeps them in at first. 

    You can do multiple at once, but you must very carefully handle certain corner cases, such as when a user adds a document but then removes the row (if using an editable grid, for example), because even if you clear out the rule input storing the id from the uploaded document, the document will still be uploaded when the form is submitted (the only way to make this not happen is to force the user to clear the upload field prior to being able to remove a row... this is my normal approach actually).

  • 0
    Certified Lead Developer
    in reply to Mike Schmitt

    Yeah the fact that it's documents does complicate things a good deal, doesn't it?

  • 0
    Certified Lead Developer
    in reply to Dave Lewis

    for real.  especially since there's still no "officially supported" way to access the document properties like name, extension and size (outside of a validation) prior to submission.  at least the "temporary document id" issue is resolved in current versions.