Plug-In: Share Link
Summons a Share Panel for the selected project or task.
Return to: OmniFocus Plug-In Collection
Share Link
/*{
"type": "action",
"targets": ["omnifocus"],
"author": "Otto Automator",
"identifier": "com.omni-automation.of.share-link",
"version": "1.1",
"description": "Summons a Share Panel for the selected project or task.",
"label": "Share Link",
"shortLabel": "Share Link",
"paletteLabel": "Share Link",
"image": "square.and.arrow.up"
}*/
(() => {
const action = new PlugIn.Action(async function(selection, sender){
if (selection.tasks.length === 1){
var selectedItem = selection.tasks[0]
var itemType = "TASK"
} else {
var selectedItem = selection.projects[0]
var itemType = "PROJECT"
}
itemName = selectedItem.name
itemID = selectedItem.id.primaryKey
itemURL = URL.fromString(`omnifocus:///task/${itemID}`)
itemNote = selectedItem.note
if(!itemNote){itemNote = ""}
if(selectedItem.dueDate){
console.log(selectedItem.dueDate.toString())
fmtr = Formatter.Date.withFormat('MM/dd/yyyy @ h:mm a')
dueDateString = fmtr.stringFromDate(selectedItem.dueDate)
var sharePanelValues = [
`${itemType}: ${itemName}`,
`DUE: ${dueDateString}`,
itemURL,
itemNote
]
} else {
var sharePanelValues = [`${itemType}: ${itemName}`, itemURL, itemNote]
}
sharePanel = new SharePanel(sharePanelValues)
shareResult = await sharePanel.show()
});
action.validate = function(selection, sender){
return ((selection.tasks.length + selection.projects.length) === 1)
};
return action;
})();