Related Documents via browse and upload

Discussions about Forms Designer for SharePoint 2013 / 2016 and Office 365.
Locked
Jaydius
Posts: 43
Joined: Thu Nov 12, 2015

06 Mar 2016

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.

User avatar
Dmitry Kozlov
Site Admin
Posts: 1524
Joined: Thu Jun 07, 2012

07 Mar 2016

Hi,

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

Code: Select all

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
Posts: 43
Joined: Thu Nov 12, 2015

30 Jun 2016

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
Posts: 43
Joined: Thu Nov 12, 2015

30 Jun 2016

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.

User avatar
Dmitry Kozlov
Site Admin
Posts: 1524
Joined: Thu Jun 07, 2012

01 Jul 2016

Hi,

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

Jaydius
Posts: 43
Joined: Thu Nov 12, 2015

01 Jul 2016

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.

User avatar
Dmitry Kozlov
Site Admin
Posts: 1524
Joined: Thu Jun 07, 2012

04 Jul 2016

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/librar ... e.14).aspx

Jaydius
Posts: 43
Joined: Thu Nov 12, 2015

04 Jul 2016

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

Locked
  • Information
  • Who is online

    Users browsing this forum: No registered users and 4 guests