URL query to get UUID for latest draft?

Maybe I’m misreading the docs, but it really looks like you can only get a draft by already knowing the UUID. I’m trying to build a URL-based workflow that lets me get the last edited draft and do a whole bunch of things to it.

Here are a couple of Javascript functions that should give you the UUID of the last created and the last modified draft.

function draftLastCreatedUUID()
{
	let allDrafts = Draft.query("", "all", []);
	allDrafts = allDrafts.sort(function(draftA, draftB)
	{
		return draftB.createdAt - draftA.createdAt
	});
	return allDrafts[0].uuid;
}

function draftLastModifiedUUID()
{
	let allDrafts = Draft.query("", "all", []);
	allDrafts = allDrafts.sort(function(draftA, draftB)
	{
		return draftB.modifiedAt - draftA.modifiedAt
	});
	return allDrafts[0].uuid;
}

Here’s some simple alert examls making use of them.

alert("Last Created UUID = " + draftLastCreatedUUID());
alert("Last Modified UUID = " + draftLastModifiedUUID());

If you build an action that uses one of these, then you can either act directly on the draft defined by the UUID (e.g. build a load last created draft action using it that you can incude in other actions) within that action or you can build an action to return it to your app that is using the URL call so that it can be used in a subsequent call.

Hope that helps.