I can give you a JSOM example to do this:
var projContext = PS.ProjectContext.get_current();
var projects = projContext.get_projects();
var project = projects.getByGuid(projUid).get_draft();
var tasks = project.get_tasks();
var task = tasks.getByGuid(taskUid);
task.set_item(cfIntName, newValue);
var queueJob = project.update();
projContext.waitForQueueAsync(queueJob, 60,
Function.createDelegate(this, function(res) {
// Publish project here
}), function(error) {
console.error(error);
});
That should be complete (though I pulled it from a script, so check the success / failure handlers which I truncated)
From memory poking around in the CSOM there is no "set_item(cf, val)" helper method to use, but it was similar, I think the property is set on the object instance via an indexer, e.g.:
(sudo c# code)
var draftTask = [get task instance];
draftTask[cfInternalName] = "Some value";
etc.
If that doesn't help then you can always reflect the ProjectServer.Client.DLL and you'll see the internal implementation of "SetCustomFieldValue" which is not publicly exposed.
Hope that helps someone.