Skip to content

Clear a Value from a Field for All Documents in a Batch

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.

The Index App shows items as indexed based on a piece of metadata called CS5MarkAsIndexed. In a few circumstances, we've needed to reset these items to not show as indexed for specific workflows.

Below is an example of how we would remove a value from that field to reset this status using the Modify Your Metadata step.

Full Script

batch.Documents.forEach(function (doc) {
     var RemoveIndexBool = doc.Metadata["General"]["CS5MarkAsIndexed"];
     if (RemoveIndexBool === true) { 
          builder.SetDocumentMetadata(doc.DocumentId, "General", "CS5MarkAsIndexed", false);
  }
})

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);