Skip to content

Add an Uploaded Document's URL to a Field Value

Legacy (Process Designer)

This page describes a script for the Modify Your Metadata activity of Process Designer. It was replaced by the Custom Step in Workflow. The script may not run as a Custom Step without changes. For new work, use the Custom Step reference.

Once a document has gone through an Upload to Destination step, a field called DocURL is filled out containing the URL to a document when released to Microsoft SharePoint.

This field is filled in within the General section of a document's metadata and not the index section where it can be seen within the monitor. Below is how you can populate this value using the Modify Your Metadata activity.

Full Script

var fieldToSet = "DocURL";

batch.Documents.forEach(function (doc)
{
    var docUrlValue = doc.Metadata["General"]["DocURL"];
    if (!(fieldToCheck == null || fieldToCheck.trim() === ''))
    {
        builder.SetDocumentMetadata(doc.DocumentId, "Index", fieldToSet, docUrlValue);
    }
});

Walkthrough

  1. First, we want to define DocURL as a variable we label fieldToSet to be used later.
var fieldToSet = "DocURL";
  1. Then, we will use a forEach to cycle through each document to perform our task on all documents.

    batch.Documents.forEach(function (doc)
    

  2. From there, you will set a new variable called DocUrlValue to the general metadata value of DocURL as mentioned in the description above.

    var docUrlValue = doc.Metadata["General"]["DocURL"];
    if (!(fieldToCheck == null || fieldToCheck.trim() === ''))
    

This will only be present after an Upload to Destination has been performed.

  1. Finally, we will use SetDocoumentMetadata to set the fieldToSet (DocURL) with our docUrlValue from step 3 in the Index section.
    builder.SetDocumentMetadata(doc.DocumentId, "Index", fieldToSet, docUrlValue);
    

You should now see a DocURL field shown in the monitor once a document has been uploaded to SharePoint.