Using Advanced Merge Field Notation (AMN) with Pocket Developer Any Any Date, Anywhere plugin in an HTTP Post in Campaign Builder, you can automatically mark tasks complete.
In order to mark a task complete, you need to set the CompletionDate field on the ContactAction table complete. (The ContactAction table is where tasks, appointments, and notes are stored. See Working with tasks, appointments, and notes for more details.) Doing so with AnyDate is as simple as setting the saveTo parameter to the value “ContactAction.CompletionDate”. However, this will ONLY work properly if the task you want to mark complete is the most recently created task, appointment, or note.
To reliably mark the correct task complete, we need to first “prefetch” the id number of the task and store it in a variable. We will then insert that variable in parentheses after the table name, so that when Pocket Developer retrieves the table it gets the entry with that specific id number, rather than the most recently created entry.
To start with, we want to tell PDev to get the Id number from the ContactAction table, so set the prefetch value to:
ContactAction.Id
Then we want to filter the table for just tasks that are not complete, so we’re going to use AMN in our prefetch value:
ContactAction.Id.FilterBy(ObjectType:Task,CompletionDate:~null~)
We’ve now targeted the most recently created incomplete task to mark as incomplete. (Well, we need to add that id number in parenthesis in the saveTo value, but more on that later.) This may be enough to reliably target the task to mark complete. But in the event the task we want is older, we can continue to add FilterBy criteria. Let’s say the task always has the Action Description “Feed Unicorns”, we can search for that specific description:
ContactAction.Id.FilterBy(ObjectType:Task,CompletionDate:~null~,
ActionDescription:"Feed Unicorns")
Note that the wildcard % is available, so if the task always starts with “Feed” but might be “Feed Unicorns” or “Feed Vampires”, we can use:
ContactAction.Id.FilterBy(ObjectType:Task,CompletionDate:~null~,
ActionDescription:"Feed %")
to get the most recent of either kind of task.
Once you have filtered for the specific task id, we just need to make sure the task id variable is used in the saveTo value. The variable is labeled in brackets after the “prefetch” name, so the complete prefetch name/value line will look like this:
prefetch[taskid] = ContactAction.Id.FilterBy(ObjectType:Task,CompletionDate:~null~,
ActionDescription:"Feed Unicorns")
The prefetch label can be anything, but must contain some alphabetic characters (i.e., not numbers only) and should have no spaces or special characters. In this case we’ve used “taskid” as a clear label of what the variable contains. We will insert this label in curly braces where we want the variable value to be used. In this case, we want to use it in parentheses after the table name, so as to identify the specific entity to change.
saveTo = ContactAction({taskid}).CompletionDate
We just have to set up the HTTP Post in the campaign where we want the task to be marked complete, and we’re done! Here’s what the HTTP Post looks like in the end: