Action

Process Daily

Posted by sylumer, Last update almost 4 years ago - Unlisted

Steps

  • defineTemplateTag

    name
    REMINDER_LIST
    template
    Test List
  • script

    function processReminderLine(p_strReminderLine)
    {
    	const DTMARK = " at ";
    	const rmlAddTo = ReminderList.findOrCreate(draft.getTemplateTag("REMINDER_LIST"));
    	let rmNew = rmlAddTo.createReminder();
    
    	if(p_strReminderLine != "")
    	{
    		let strReminder = p_strReminderLine.substring(4);
    		rmNew.title = strReminder;
    		if(strReminder.includes(DTMARK))
    		{
    			let strDueReminder;
    			let strDueTime;
    			[strDueReminder, strDueTime] = strReminder.split(DTMARK);
    			if (Date.parse(strDueTime) != null)
    			{
    				rmNew.dueDateIncludesTime = true;
    				rmNew.title = strDueReminder;
    				rmNew.dueDate = Date.parse(strDueTime);
    			}
    		}
    		rmNew.update();
    	}
    }
    
    let astrSections = draft.content.split("\n____\n");
    astrSections[0].split("\n").map(strLine => processReminderLine(strLine.trim()));
    draft.setTemplateTag("en_billable", astrSections[1]);
    draft.setTemplateTag("en_tofile", astrSections[2]);
    
    
  • script

    //Add billable note
    
    let method = "execute";
    let script = `on execute(titleText, tagList, htmlContent)
    	tell application "Evernote Legacy"
    		set theNote to create note with text titleText title titleText tags tagList
    		set HTML content of theNote to htmlContent
    	end tell
    end execute`;
    
    let title = draft.processTemplate("[[date]] Billable");
    let tags = ["billable"];
    let html = draft.processTemplate(`%%[[en_billable]]%%`);
    
    let runner = AppleScript.create(script);
    if (!runner.execute(method, [title, tags, html]))
    {
    	console.log(runner.lastError);
    	context.fail();
    }
  • script

    //Add reference note
    
    title = draft.processTemplate("[[date]] Reference");
    tags = ["reference"];
    html = draft.processTemplate(`%%[[en_toFile]]%%`);
    
    runner = AppleScript.create(script);
    if (!runner.execute(method, [title, tags, html]))
    {
    	console.log(runner.lastError);
    	context.fail();
    }

Options

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