Related Documents via browse and upload

rss

Posted by Jaydius - Mar 6 ’16 at 09:07

I enjoy the ease of use of the fd.updateDroppedDocuments function in Forms Designer.  Im wondering if theres a way to incorporate the ability for a user to use the standard browse function to find and then upload a file, if they prefer the old method to dragging and dropping.

It would be great to have the option to click on a button to browse for chosen file(s) to upload, then for the form to pre-fill the values in the same way the current fd.updateDroppedDocuments function does.

  • Dmitry Kozlov
    Dmitry Kozlov
    Admin
    Member for: 8 years 4 months 7 days
    #1 by Dmitry Kozlov Mar 7 ’16 at 07:40

    Hi,

    You can pre-populate fields on the edit form of a document right after uploading by using the code below:

    fd.field('TargetField').value(window.top.fd.field('SourceField').value());

    Replace 'TargetField' and 'SourceField' with the internal names of the appropriate field in the parent and child forms.

  • Jaydius
    Member
    Member for: 6 years 2 months 16 days
    #2 by Jaydius Jun 30 ’16 at 06:51

    [#1]: Ive been trying to get this working.  Ive inserted the following into the Javascript panel in SPForm for the Edit Form in the document library:

    fd.field('AWO').value(window.top.fd.field('ID').value());

     

    But it doesnt seem to carry through to the edit form after uploading.  As the AWO field is a lookup field (lists all Parent records) could this be causing the issue?  Im using the Related Items control in the parent form, filtering documents that share the same 'AWO' value from the document library.  Ive set the control to Editable, then using the 'Upload' button to upload a new associated document.

    Once the file is uploaded it redirects to the edit form, but the code above doesnt seem to populate the AWO field.

    Also, I dont know if this would be a factor, but the parent form is opening in a dialog, not full page.

  • Jaydius
    Member
    Member for: 6 years 2 months 16 days
    #3 by Jaydius Jun 30 ’16 at 10:47

    After some more testing, using the following works to get the parent ID at least:

    fd.field('AWO').value(fd.getSourceID());

    It would be great to get more than just the ID from the parent form to populate the child form though.  Any help would be much appreciated.

  • Dmitry Kozlov
    Dmitry Kozlov
    Admin
    Member for: 8 years 4 months 7 days
    #4 by Dmitry Kozlov Jul 1 ’16 at 05:21

    [#3]: Hi,

    Try to open the parent form in the main window (not in a dialog).

  • Jaydius
    Member
    Member for: 6 years 2 months 16 days
    #5 by Jaydius Jul 1 ’16 at 07:12

    The users of the system prefer the forms opening in dialog vs full window.  Is there any way I can still pass values on to the child form after document upload? As I mentioned, I'm able to get the parent ID to pull through, just unsure how to get any other values.

  • Dmitry Kozlov
    Dmitry Kozlov
    Admin
    Member for: 8 years 4 months 7 days
    #6 by Dmitry Kozlov Jul 4 ’16 at 04:58

    [#5]: If a user opens both forms in dialogs, you can use the following code to retrieve field values from the first dialog:

    var iframes = $('iframe.ms-dlgFrame', window.top.document);
    var parentFD = iframes[0].contentWindow.fd;
    alert(parentFD.field('Title').value);
    

    Another option is getting field values via JSOM:

    https://msdn.microsoft.com/en-us/library/office/hh185007(v=office.14).aspx

  • Jaydius
    Member
    Member for: 6 years 2 months 16 days
    #7 by Jaydius Jul 4 ’16 at 05:05

    Using fd.field('Childformfield').value(parentFD.field('Parentformfield').value()); works perfectly with your code.  Thanks again for another problem solved.  Much appreciated Dmitry!

Displaying 1 to 7 of 7 messages