Forum Archive

Create New Workflow Action?

TutorialDoctor

I am wondering if there is a way to create a Create New Workflow action.

I know workflow files are json files, and figuring the format won't be so hard.

Perhaps a New Workflow from Clipboard action? Or a New workflow from Input action?

ClareMacrae

Are you aware that you can already create copies of existing Workflows, in the UI?

What are you trying to achieve?

And what did you have in mind on the Clipboard or Input? A name? A workflow? A JSON string?

It's hard for me to see how this would be useful in practice, so I am wondering if I have misunderstood.

Clare

MartinPacker

Well, I can imagine the OP might be contemplating something that builds custom workflows - for example a proforma maker.

One of the beauties of a text-based format is the ability to confect it - which unlocks rather a lot of creative possibilities.

TutorialDoctor

Yes, I want to build custom workflows textually. I could also change variables of a workflow without editing it.

This will indeed open up more possibilities.

I have copied a workflow to the clipboard and edited it in the editor, then copied the text, and created a new workflow from the clipboard. It was a simple test, but I could change variables this way also.

Even if I could get a Copy Workflow action. Or an Update Workflow action....

ClareMacrae

Thanks for the replies - here's another use case:

  • I've got a file open, that I open a lot - and I want to create a Workflow that gets the path of this current document, and opens the file

Here's some steps that gave me a suggestion for how to get most of the way with implementing this:

  • In Editorial, edit an existing workflow
  • Select the "Send to..." button and select "Copy Workflow"
  • Now, back in the Editorial editor, create-and-open a new text file - Markdown or plain text
  • Paste the clipboard in to a new document - this will insert text representing the workflow you were editing

This is what the content looks like, for a workflow called "My Workflow", with a single HUD display that says "Hello World".

------------ BEGIN WORKFLOW ------------
{
  "actions" : [
    {
      "class" : "WorkflowActionShowHUD",
      "pauseBeforeRunning" : false,
      "customTitle" : "",
      "parameters" : {
        "icon" : 0,
        "duration" : 0,
        "HUDText" : {
          "tokenRanges" : {

          },
          "type" : "advancedText",
          "text" : "Hello World"
        }
      },
      "pauseWithoutShowingParameters" : false
    }
  ],
  "name" : "My Workflow"
}
------------- END WORKFLOW -------------

How to use this programmatically:

  • This means that it's possible to write a Python script that generates text such as the above, including the BEGIN WORKFLOW and END WORKFLOW lines
  • Then put that on the clipboard
  • Then, to actually add the new workflow, you just do Workflows > Edit > '+', and it will offer to create the new workflow from the clipboard

All the alternative approaches I'd considered involved:

  • creating a new .wkflw file,
  • and adding new lines to Commands.edcmd on Editorial's folder in the iOS file system
  • figuring out the meaning of the uuid/GUID magic strings used for naming the .wkflw files - in order to generate new files
  • those files are all in formats that are officially undocumented, so that would be way more scary than the above, and also way more susceptible to problems if the format changed in future
ClareMacrae

So far, I haven't managed to persuade it to accept comment or tags values via this route - it really does only seem to extract actions and name:

  • If I put any extra name/value pairs after the "name" line, the content wasn't recognised as a Workflow.
  • If I put any extra name/value pairs before the "name" line, the content was recognised OK as a Workflow, but the extra values were ignored.
TutorialDoctor

@ ClareMacrae

editor.get_path() allows you to get the path of the current document.

I have been working on a few file Managment workflows myself using the os module.

I can delete the current file, add a new file to the file list, and rename the current file via workflows.

I just don't know how to interpret the workflow file names.