Hello,
I want to “rebuild” the Omni Automation Script called “Replace Note Text with clipboard” to a silent run, meaning I do not get a confirmation anymore to replace (yes/ cancel). This way, I will be able to use it in an iOS Shortcut in Automation on time.
I tried a lot, but I do not see how to accomplish this. Is there somebody in the community who can help? This is the Omni Automation Script:
*{
"type": "action",
"targets": ["omnifocus"],
"author": "Otto Automator",
"identifier": "com.omni-automation.of.replace-note-text-with-clipboard",
"version": "1.2",
"description": "Will replace the text content of the note of the selected project or task with the text content of the clipboard.",
"label": "Replace Note Text with Clipboard",
"shortLabel": "Replace Note Text",
"paletteLabel": "Replace Note Text",
"image": "arrow.right.doc.on.clipboard"
}*/
(() => {
const action = new PlugIn.Action(function(selection, sender){
try {
if (selection.tasks.length === 1){
var item = selection.tasks[0]
} else if(selection.projects.length === 1){
var item = selection.projects[0]
} else {
throw {"name":"Selection Error", "message":"Please select a single project or task."}
}
var alertTitle = "CONFIRMATION"
var alertMessage = "Replace note text with text from the clipboard?"
var alert = new Alert(alertTitle, alertMessage)
alert.addOption("Replace")
alert.addOption("Cancel")
alert.show(buttonIndex => {
if (buttonIndex === 0){
if(app.userVersion.atLeast(new Version("4"))){
// show note
tree = document.windows[0].content
node = tree.nodeForObject(item)
node.expandNote(true)
}
// replace text
console.log(item)
item.note = Pasteboard.general.string
}
})
}
catch(err){
new Alert(err.name, err.message).show()
}
});
action.validate = function(selection, sender){
return (
Pasteboard.general.hasStrings &&
selection.databaseObjects.length === 1
)
};
return action;
})();
```/*{
"type": "action",
"targets": ["omnifocus"],
"author": "Otto Automator",
"identifier": "com.omni-automation.of.replace-note-text-with-clipboard",
"version": "1.2",
"description": "Will replace the text content of the note of the selected project or task with the text content of the clipboard.",
"label": "Replace Note Text with Clipboard",
"shortLabel": "Replace Note Text",
"paletteLabel": "Replace Note Text",
"image": "arrow.right.doc.on.clipboard"
}*/
(() => {
const action = new PlugIn.Action(function(selection, sender){
try {
if (selection.tasks.length === 1){
var item = selection.tasks[0]
} else if(selection.projects.length === 1){
var item = selection.projects[0]
} else {
throw {"name":"Selection Error", "message":"Please select a single project or task."}
}
var alertTitle = "CONFIRMATION"
var alertMessage = "Replace note text with text from the clipboard?"
var alert = new Alert(alertTitle, alertMessage)
alert.addOption("Replace")
alert.addOption("Cancel")
alert.show(buttonIndex => {
if (buttonIndex === 0){
if(app.userVersion.atLeast(new Version("4"))){
// show note
tree = document.windows[0].content
node = tree.nodeForObject(item)
node.expandNote(true)
}
// replace text
console.log(item)
item.note = Pasteboard.general.string
}
})
}
catch(err){
new Alert(err.name, err.message).show()
}
});
action.validate = function(selection, sender){
return (
Pasteboard.general.hasStrings &&
selection.databaseObjects.length === 1
)
};
return action;
})();