Forums

Forums / Developing Portals / Update Entity record with File Upload Submission

Update Entity record with File Upload Submission

4 posts, 1 answered
  1. Chris Williams
    Chris Williams avatar
    16 posts
    Registered:
    27 Jan 2020
    16 Jul 2020
    Link to this post
    Hello,
    I have a form that allows users to add additional files to an existing record. 
    Is it possible to also update other fields within that record with the same File Upload submission?
    ie:
    TpcFileUploadController.add_click(function (e) {
       // set value of field on submission
        someControl.set_value("newValue");
      });
    Thanks
  2. Josh
    Josh avatar
    47 posts
    Registered:
    01 Jun 2018
    20 Jul 2020 in reply to Chris Williams
    Link to this post
    Hello Chris,

    Thank you for your question. I will need to gather some additional information to provide you with the best answer as there are multiple approaches you could take.

    1) Are you looking to update the value of another field in the TPC Form when a file is uploaded to the TPC File Upload widget OR when the form is submitted?

    2) Are you looking for a solution using JavaScript (client-side) or C# (server-side) code?

    Cheers,

    Josh
  3. Chris Williams
    Chris Williams avatar
    16 posts
    Registered:
    27 Jan 2020
    21 Jul 2020 in reply to Josh
    Link to this post
    Hi Josh, 
    I am looking to submit a field value at the same time as uploading an image with the file upload controller, using client side Javascript.
    I will join a Q&A to discuss further.
    Thanks
  4. Patrick
    Patrick avatar
    33 posts
    Registered:
    20 Apr 2020
    Answered
    05 Aug 2020 in reply to Chris Williams
    Link to this post
    Hi Chris,

    Sorry for the late response. You can use the pre-validate event on the form to check the file upload widget (see here for documentation on our form submission events: https://www.crmportalconnector.com/developer-network/documentation/developing-for-tpc/portal-form-submission-events). If the file upload widget contains the files you want, update the field in the form. This will add the field to the form collection to be submitted with your uploaded files.

    Here is a basic example that might help:
    $(document).on("tpc:pre-validate", function (event, form, sender) {
        var files = tpc.forms.sf_fileuploadtest.fileupload.get_kendoInput().getFiles();
        if (files.length > 0)
            tpc.forms.sf_fileuploadtest.fileattachedcheck.set_value('File Attached');
    });

    Thanks,

    Patrick
4 posts, 1 answered