OmniOutliner & Workflow: Pic to Row

Some of the most useful automated processes are those that involve more than one application, requiring many calculated steps, and are guided by user input. This workflow for choosing a photo and adding to an outline is one such example.

Apple’s Workflow application handles the selection and processing of the chosen image, and then passes the image data to an Ommi Automaton script for inserting the image into a new row in an open outline document.

And the best part is that is all happens automatically in seconds! (Watch)

The Omni Automation Script

The automation scenario demonstrated by this example is in two parts, the first of which is handled by the Workflow app performing the following tasks:

With those tasks accomplished, it is up to the launched Omni Automation script to:

Here is the Omni Automation script:

try { var imageName = 'XXXXX' var imageFileExtension = 'YYYYY' var image64Str = 'ZZZZZ' var colTitle = 'Image' columnTitles = columns.map(function(col){ return col.title }) if(columnTitles.indexOf(colTitle) === -1){ alertMsg = 'There is no column titled “' + colTitle + '” in this outline.' var alert = new Alert('Missing Column',alertMsg) alert.addOption('Cancel') alert.show(function(result){}) } else { imageData = Data.fromBase64(image64Str) imageFileName = imageName + '.' + imageFileExtension wrapper = FileWrapper.withContents(imageFileName,imageData) textObj = Text.makeFileAttachment(wrapper, document.outline.baseStyle) rootItem.addChild( null, function(item){ item.topic = imageName item.setValueForColumn(textObj,columns.byTitle('Image')) } ) } } catch (err){ var alert = new Alert('Script Error',err) alert.show(function(result){}) }

 01-30  The script is wrapped in an error handler that displays, in OmniOutliner, a dialog with the error message.

 02-04  During the workflow execution, the placeholders (XXXXX, YYYYY, ZZZZZ) are replaced with the chosen image’s name, file extension, and base64 data. In these script statements, those items are placed into declared variables.

 05  The name of the column in which to insert the image.

 06-08  Get a list of the column titles.

 09  Check to see if the list of column titles contain the designated column title.

 10-13  If the list of column titles does not contain the designated title, display an error message to the user.

 15  Create an instance of the Data class from the base64 string.

 16-17  Create an instance of the FileWrapper class using the image name and extension, and the image data object.

 18  Create a Text Attachment object using the FileWrapper instance.

 19-25  Add a new row at the default postion (end of rows) and insert the image name in the topic column and the image in the designated column.

The Workflow

As described previously, the Workflow document shown below does some “heavy lifting” in this automation scenario, by performing the following tasks:

You can get this workflow here, and download the example OmniOutliner document here.

workflow-outline
UNDER CONSTRUCTION

This webpage is in the process of being developed. Any content may change and may not be accurate or complete at this time.

DISCLAIMER

 

✕︎