0
votes

I am a newbie with SharePoint. I have set up a document library. One of the columns is a unique id for a document. Another column called Related Document is a lookup field that may contain a clickable link to another document's unique id.

How to automatically fill in related document column with the link to the original document? That is, if I make document A be related to document B, I would like to automatically add a relationship from B to A as well. Not sure if it's possible to do with Related items feature - it does not seem to allow a clickable link.

Thank you.

2

2 Answers

0
votes

The only way I can realistically see this being done is with a Remote Event Receiver. https://msdn.microsoft.com/en-us/library/office/jj220043.aspx

I can't think of a way out of the box that would do this.

You will need to create a SharePoint Add-in and deploy it to your SP Online instance. The remote code will get hosted on an Azure instance.

The remote code will get triggered when a document is updated.

You can then get a reference to the related document and fill in the related document link field accordingly.

0
votes

You can pass parameters with the source parameter of SharePoint. This is actually to forward an URL to jump back to, but can be used to automatically pass parameters to the second form of the library. Here is a small function that opens an upload dialog e.g. to be inserted in a content editor WebPart:

function openUploadDialog(passParameterName, passParameterValue)
{
    var dialogOptions = SP.UI.$create_DialogOptions();
    dialogOptions.url = "/_layouts/15/Upload.aspx?List=[INSERT_LIST_ID_HERE]&RootFolder=&IsDlg=1&source=%2fSitePages%2f[SOME_SITE_OF_YOURS].aspx%3f" + encodeURIComponent(passParameterName) + "%3d" + encodeURIComponent(passParameterValue);
    dialogOptions.width = 700;
    dialogOptions.height = 310;
    dialogOptions.title = "Submit Document";
    dialogOptions.dialogReturnValueCallback = Function.createDelegate(null, CloseThisDocCallBack);
    SP.UI.ModalDialog.showModalDialog(dialogOptions);
}

openUploadDialog([NAME_OF_YOUR_ID], [VALUE_OF_YOUR_ID])

Short:

  • Add a field with the ID (or whatever you want) to your Library
  • Create a Content Editor or script WebPart where every you want and use the function to open a dialog
  • look at the source of this webpart to find out the DOM ID of the field
  • Add another webpart to your Upload Form (Ribbon => Library => Form Webparts => Default Editor Form) to take the value from the source paramter (e.g. via JQuery) and write it into the new field you've just created.

Something like this:

id = GetUrlKeyValue('[NAME_OF_YOUR_ID]');
$('#[DOM_ID_OF_YOUR_CUSTOM_FIELD]').val(id);

I used this once to add an ID of a list element to the file. Hope that this is what you were looking for.