Updating a Task
Posted: Fri Oct 05, 2018 2:08 pm
HI,
I'm able to retrieve the correct Order and find the desired Task using the SDK/API in a console app like this:
var os = _ss.GetService<IOrderStore>();
var orderinfo = os.Orders.Where(x => x.Number == row.Number).FirstOrDefault();
var order = os.OpenOrder(orderinfo);
var tasks = order.GetProperty("Tasks");
dynamic t = (dynamic)tasks;
Plus a For loop that iterates through "t" to identify the Task to be updated.
What is the best way to then make the update to the Task and save it back to the db through the SDK?
In the SDK documentation that refers to creating a new Note, the ApplyChanges method on the Order object is used to add a new Note. Would updating a Note (or Task in this case) be handled in a similar way?
Alternatively, the ITaskManager has an ApplyChanges method as well. Would it be a better approach to find the Task like i mentioned above and use the ApplyChanges method on ITaskManager instead to update the Task? If so, would I need to "unbox" the Task object I find on the Order and "rebox" it into a more appropriate Task related object type. The Task that is exposed by the Order object is some variation of a .Snapshot<Task> object, and I've tried updating that and using the ApplyChanges on Order but was unsuccessful.
Just throwing my observations out there in hope of some helpful feedback, any other input related to updating Tasks via the SDK/API using a console app would be appreciated.
Thanks.
I'm able to retrieve the correct Order and find the desired Task using the SDK/API in a console app like this:
var os = _ss.GetService<IOrderStore>();
var orderinfo = os.Orders.Where(x => x.Number == row.Number).FirstOrDefault();
var order = os.OpenOrder(orderinfo);
var tasks = order.GetProperty("Tasks");
dynamic t = (dynamic)tasks;
Plus a For loop that iterates through "t" to identify the Task to be updated.
What is the best way to then make the update to the Task and save it back to the db through the SDK?
In the SDK documentation that refers to creating a new Note, the ApplyChanges method on the Order object is used to add a new Note. Would updating a Note (or Task in this case) be handled in a similar way?
Alternatively, the ITaskManager has an ApplyChanges method as well. Would it be a better approach to find the Task like i mentioned above and use the ApplyChanges method on ITaskManager instead to update the Task? If so, would I need to "unbox" the Task object I find on the Order and "rebox" it into a more appropriate Task related object type. The Task that is exposed by the Order object is some variation of a .Snapshot<Task> object, and I've tried updating that and using the ApplyChanges on Order but was unsuccessful.
Just throwing my observations out there in hope of some helpful feedback, any other input related to updating Tasks via the SDK/API using a console app would be appreciated.
Thanks.