Plug-In: Add Call Task
This plug-in will create a new task with a TAP|CLICK call link in its notes. Optionally, you can tag the task with the default Apple phone emoji tag: ☎️
On iOS devices the keypad will be automatically used for the phone number input.
Return to: OmniFocus Plug-In Collection
Add Call Task
/*{
"type": "action",
"targets": ["omnifocus"],
"author": "Otto Automator",
"identifier": "com.omni-automation.of-add-call-task",
"version": "1.7",
"description": "This plug-in will create a new task with a call link in its notes. Option to assign tag to new task.",
"label": "Add Call Task",
"shortLabel": "Call Task",
"paletteLabel": "Call Task",
"image": "phone.bubble.fill"
}*/
(() => {
const action = new PlugIn.Action(async function(selection, sender){
try {
titleEmoji = "☎️"
taskTitlePrefix = titleEmoji + "︎ Call "
textInputField01 = new Form.Field.String(
"taskName",
"Task Title",
taskTitlePrefix
)
textInputField02 = new Form.Field.String(
"callNumber",
"[0 to 9, +, *, #]",
null
)
if (Device.current.iOS && !Device.current.iPad){
textInputField02.keyboardType = KeyboardType.PhonePad
}
textInputField03 = new Form.Field.String(
"tagName",
"Tag task with:",
null
)
inputForm = new Form()
inputForm.addField(textInputField01)
inputForm.addField(textInputField02)
inputForm.addField(textInputField03)
formPrompt = "Task title and phone number:"
if (Device.current.iOS && !Device.current.iPad){
formPrompt = "Title & Number:"
}
buttonTitle = "Continue"
formObject = await inputForm.show(formPrompt,buttonTitle)
taskName = formObject.values['taskName']
textValue = formObject.values['callNumber']
tagName = formObject.values['tagName']
if(tagName){
var result = flattenedTags.filter((tag) => tag.name === tagName)[0]
var tagObj = ((result) ? result : new Tag(tagName))
}
callURLStr = "tel://" + textValue
url = URL.fromString(callURLStr)
task = new Task(taskName)
task.note = url.string
if(tagName){task.addTag(tagObj)}
id = task.id.primaryKey
URL.fromString("omnifocus:///task/" + id).open()
}
catch(err){
if(!err.causedByUserCancelling){
console.error(err.name, err.message)
new Alert(err.name, err.message).show()
}
}
});
action.validate = function(selection, sender){
return true
};
return action;
})();