Google-apps-script – Edit custom file properties in Google Drive UI

google-apps-scriptgoogle-drive

Once I was looking through Google Drive API docs and I have seen a picture of Google Drive UI and a sidebar on the right, I guess it allowed to edit custom file properties. I need to let the user add some data to a file (like an email), so I could get it with Java SDK later.

Is it possible to edit custom properties right in Google Drive UI or that was my fantasy? Can you point out to a guide? Perhaps, it involves Google App Script or something.

Best Answer

Google Drive UI doesn't include a built-in way for end-users to edit custom properties but they could use Google Apps Script's Advanced Drive Service .

Adding custom properties

The following example demonstrates how to add a custom property to a file. Unlike Apps Script's document properties, Drive's custom file properties can be accessed outside of Apps Script and by other applications (if the visibility is set to PUBLIC).

function addCustomProperty(fileId) {
  var property = {
    key: 'department',
    value: 'Sales',
    visibility: 'PUBLIC'
  };
  Drive.Properties.insert(property, fileId);
}

Related: