Action

Load Last Modified Draft

Posted by @sylumer, Last update about 6 years ago - Unlisted

Steps

  • script

    //Function to compare draft objects by modified date and return them in reverse chronological order
    function draft_marev_compare(a, b) {
      const modatA = a.modifiedAt;
      const modatB = b.modifiedAt
    
      let modatComparison = 0;
      if (modatA < modatB) {
        modAtComparison = 1;
      } else if (modatA > modatB) {
        modAtComparison = -1;
      }
      return modAtComparison;
    }
    
    function lastModifiedDraft()
    {
    	//Get all drafts
    	let arrAllDrafts = Draft.query("", "all", []);
    	
    	//Sort all drafts by last modified date in reverse Chronological Order
    	arrAllDrafts.sort(draft_marev_compare);
    	
    	//Return the UUID of the first draft object
    	return arrAllDrafts[0];
    }
    
    //Load the last modified draft
    editor.load(lastModifiedDraft());
    editor.activate();

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.