Hi
Is anyone using this on the Mac?
https://omni-automation.com/omnifocus/plug-in-append-to-note.html
It works fine on IOS for me but, when I run it on the Mac, it doesn’t change the Notes field at all. I have tried with/without timestamps, and also with different line spacings.
Other Omni-Automation plug-ins are working fine so it seems to be something specific to this one and/or my local setup.
Has anyone got it working at all?
Thanks in advance
Just tested. That is correct.
You can try this (basic) version:
Save as a text file with .omnijs extension.
/*{
"type": "action"
}*/
// Twitter: @unlocked2412
(() => Object.assign(
new PlugIn.Action(selection => {
// OMNI JS CODE ---------------------------------------
const omniJSContext = () => {
// main :: IO ()
const main = () => {
const
promise = showForm('Enter the text to be appended to the note:')(
'OK'
)(textField(null)(Left())),
task = selection.tasks[0];
promise.then(
form => task.note = compose(
unlines,
append([task.note]),
lines
)(form.values['txt1'])
)
};
// textField :: String -> Either String String -> Omni Form
const textField = strTitle =>
lrDefault => {
const
form = new Form(),
txtField = new Form.Field.String(
'txt1',
strTitle,
isLeft(lrDefault) ? (
''
) : lrDefault.Right
);
return (
form.addField(txtField),
form
)
};
// showForm :: String -> String -> Omni Form -> Promise
const showForm = strTitle =>
strButton => form => form.show(strTitle, strButton)
// GENERIC FUNCTIONS --------------------------------------------
// https://github.com/RobTrew/prelude-jxa
// Left :: a -> Either a b
const Left = x => ({
type: 'Either',
Left: x
});
// Right :: b -> Either a b
const Right = x => ({
type: 'Either',
Right: x
});
// append (++) :: [a] -> [a] -> [a]
// append (++) :: String -> String -> String
const append = xs =>
// A list or string composed by
// the concatenation of two others.
ys => xs.concat(ys);
// compose (<<<) :: (b -> c) -> (a -> b) -> a -> c
const compose = (...fs) =>
x => fs.reduceRight((a, f) => f(a), x);
// isLeft :: Either a b -> Bool
const isLeft = lr =>
('Either' === lr.type) && (undefined !== lr.Left);
// lines :: String -> [String]
const lines = s =>
// A list of strings derived from a single
// newline-delimited string.
0 < s.length ? (
s.split(/[\r\n]/)
) : [];
// unlines :: [String] -> String
const unlines = xs =>
// A single string formed by the intercalation
// of a list of strings with the newline character.
xs.join('\n');
// MAIN -----------------------------------------
return main()
};
return omniJSContext()
}), {
validate: selection => selection.tasks.length === 1
}
))();
I notice that the appendStringToNote()
method of a Task
object is only included in the API reference on iOS, and indeed it returns an error in OF Mac.
I’m surprised it isn’t on Mac. I guess the method could be used to add text to a Rich Text note without altering the existing formatting. OF on iOS doesn’t support Rich Text notes and editing a note there converts it entirely to plain text. This is also what happens when you call appendStringToNote()
, so I don’t see any difference in the result compared to changing the note directly using .note()
as @unlocked2412 did in his script.
Thanks both … I tried @unlocked2412 code and it works for me, albeit without the options for date./time and line spacing, etc.
I’m afraid I’m not proficient in scripting to be able to combine the best of both but hopefully the original author on Omni-automation will pick up on this and update the source one. I’m not sure how we provide feedback via the Omni-Automation site however.
I may have a tinker with @unlocked2412 code and see if I can piece together the missing pieces when I get a few minutes.
Thanks for the prompt feedback from you both