Build Daily

Posted by sylumer, Last update 3 months ago - Unlisted


  • script

    function constructDaily(p_strTemplateUUID)
    	//Get the tag matches
    	let drTemplate = Draft.find(p_strTemplateUUID);
    	let regexDailyTag = /\+{(.*)}\+/g;
    	let astrDailyTags = drTemplate.content.match(regexDailyTag);
    	astrDailyTags = => {return strDailyTag.replace(/\+{|}\+/g, '');});
    	//Set the output
    	let strOutput = drTemplate.content;
    	//Process each substitution tag in the template => {
    		//Build query date for today
    		let qdCreated = new QueryDate();
    		qdCreated.field = "created"
    		qdCreated.type = "absolute" =;
    		//Make a temporary Workspace
    		let wsDaily = Workspace.create();
    		wsDaily.setInboxSort("created", false, false);
    		//Technically we could have something generate a future dated draft, so
    		//for the sake of one line, let's be specific.
    		wsDaily.startDate = qdCreated;
    		wsDaily.endDate = qdCreated;
    		//Apply a tag filter
    		wsDaily.tagFilter = strDailyTag;
    		//Get the drafts in the Workspace and concatenate their content
    		let adrDailyTagged = wsDaily.query("inbox");
    		let strDailyTaggedContent = => {return drMatch.content}).join("\n");
    		//Account for no tags that day
    		if(strDailyTaggedContent == "") strDailyTaggedContent = "Nothing.";
    		//Substitute in the concatenated results to the output
    		let reDailyTag = new RegExp("\\+{" + strDailyTag + "}\\+","g");
    		strOutput = strOutput.replace(reDailyTag,strDailyTaggedContent);
    		//Untag and archive the drafts in the workspace => {
    			drMatched.isArchived = true;
    	//Output built from template content to new draft
    	let drNew = Draft.create();
    	drNew.content = strOutput;
    	//Load the new draft


  • 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.