Action

Split Lines to New Drafts With Entered Tag

Posted by sylumer, Last update over 3 years ago - Unlisted

Splits a line to new Drafts.

A new draft is created for every non-blank line, with that line as its content. The user is also prompted to enter a single tag which is automatically added to each new draft.

Steps

  • prompt

    promptKey
    basetag
    promptTitle
    Enter Tag
    promptMessage
    Enter a tag to be added to each new draft split from this one.
    promptButtons
    OK
    includeTextField
    true
    textFieldDefault
    includeCancelButton
    true
  • script

    let intCounter = 0;
    draft.content.split("\n").forEach(function(strLine)
    {
    	if (strLine.trim().length > 0 )
    	{
    		let draftNew = new Draft;
    		draftNew.content = strLine;
    		draftNew.addTag(draft.getTemplateTag("basetag_text"));
    		draftNew.update();
    		intCounter++;
    	}
    });
    app.displayInfoMessage(`${intCounter} drafts created.`);

Options

  • After Success Default
    Notification Error
    Log Level Error
Items available in the Drafts Directory are uploaded by community members. Use appropriate caution reviewing downloaded items before use.