pritchardhobe Posted February 1, 2017 Report Share Posted February 1, 2017 Working on adjusting our automated submissions where we move from a multitude of projects over to a single project w/multiple requests and i've hit a bit of a roadblock. I'm running two functions now (createParentTask and createTask both included here). ParentTask works just fine, creates the correct task in the right place parented to the main project. Problem i'm having is creating tasks attached to the parentTask and i can't get a true handle on where the error is. The idea is that createTask would parent it to the previously created ParentTask. //Create the initial task that will host all sub tasks. This is tied to the main project function createParentTask(task, project) { var taskObj = { context_type: "task", name: task, parent_id: project.id, project: project, object_type_id: "c84ec37e-d787-11e6-9d0c-0a580a280613", bid: 0, priority_id: $scope.selectedPriority.priority_id, status_id: "29c8fb88-62c2-11e5-a7f9-42010af0e994", type_id: "29a2638a-d78b-11e6-bd3f-0a580a280613" } return session.create("Task", taskObj); } function createTask(task, project) { console.log(project.id + " " + project.project_id + " " + task); var taskObj = { context_type: "task", name: task, parent_id: project.id, project: project.parent_id, object_type_id: "11c137c0-ee7e-4f9c-91c5-8c77cec22b2c", bid: 0, priority_id: $scope.selectedPriority.priority_id, status_id: "29c8fb88-62c2-11e5-a7f9-42010af0e994", type_id: "29a2638a-d78b-11e6-bd3f-0a580a280613" } console.log("Creating Task" + taskObj.context_type + " " + taskObj.parent_id + " " + taskObj.type_id + " " + taskObj.project); return session.create("Task", taskObj); } Errors are extremely vague.. Uncaught (in promise) TypeError: b.ServerError is not a constructor at ftrack.min.js:10 (anonymous) @ ftrack.min.js:10 and in the networking tab under each api call that errors i get.. {content: "'unicode' object has no attribute '_sa_instance_state'", exception: "AttributeError"} content:"'unicode' object has no attribute '_sa_instance_state'" exception:"AttributeError" Thanks in advance! Link to comment Share on other sites More sharing options...
Mattias Lagergren Posted February 2, 2017 Report Share Posted February 2, 2017 9 hours ago, pritchardhobe said: Errors are extremely vague.. Uncaught (in promise) TypeError: b.ServerError is not a constructor at ftrack.min.js:10 (anonymous) @ ftrack.min.js:10 Yes, vague indeed - looks like an internal error leaking through. I've just looked into this briefly but the error might have to do with setting the "project". Does it work better if you mimic this (replace with your corresponding ids): session.create('Task', { name: 'foo', object_type_id: '11c137c0-ee7e-4f9c-91c5-8c77cec22b2c', parent_id: '81b98c47-5910-11e4-901f-3c0754282242', project_id: '81b98c47-5910-11e4-901f-3c0754282242', priority_id: '34049ad2-58dc-11e2-93e8-f23c91df25eb', status_id: '44dd9fb2-4164-11df-9218-0019bb4983d8', type_id: '44dc3636-4164-11df-9218-0019bb4983d8', }); Link to comment Share on other sites More sharing options...
pritchardhobe Posted February 2, 2017 Author Report Share Posted February 2, 2017 Yea that does work as i'm doing that w/the task above (parenttask). It does appear that the issue shows itself when i try to link a task to a task. I've tried using the parentTask id for both parent and project as wall as as the parenttask.id and parenttask.parent_id but still keeps giving me that error. Link to comment Share on other sites More sharing options...
Mattias Lagergren Posted February 3, 2017 Report Share Posted February 3, 2017 You should be able to: ... parent_id: <parent-task-id>, project_id: <project-id-of-parent-task> ... Do you get any errors when doing this? Link to comment Share on other sites More sharing options...
pritchardhobe Posted February 3, 2017 Author Report Share Posted February 3, 2017 Yea thats how i have it now. I've tried... parent_id, project_id, project.project.id and none seem to work if thats actually the connection to the error.. which seems to be the case. Its essentially like it doesn't like the fact its being created under a project. Does it need a second step? Maybe create the task to the main project first, then run a second step to push it under the necessary task? Link to comment Share on other sites More sharing options...
pritchardhobe Posted February 3, 2017 Author Report Share Posted February 3, 2017 Quick update to this.. I've changed the variable i pass in to a new one, and use that for the response data from the ParentTask and it gets a little further. Its still erroring in a vague way but the API output in the network window gives me this twice, which would indicate to me its something to do w/the tying the two tasks i created to the parent task. "Bidirectional attribute conflict detected: Passing object <Task at 0x7fe0da1bbad0> to attribute "Task.show" triggers a modify event on attribute "Task.ancestors" via the backref "Task.descendants"." exception:"ValueError" Link to comment Share on other sites More sharing options...
pritchardhobe Posted February 3, 2017 Author Report Share Posted February 3, 2017 Welp looks like user error. I had an incorrect TYPE_ID in the task creation process... not sure at all why it wasn't working as it was a valid type but i think it might have been a type that wasn't part of the project schema. Link to comment Share on other sites More sharing options...
Mattias Lagergren Posted February 6, 2017 Report Share Posted February 6, 2017 On 03/02/2017 at 10:45 PM, pritchardhobe said: Welp looks like user error. I had an incorrect TYPE_ID in the task creation process... not sure at all why it wasn't working as it was a valid type but i think it might have been a type that wasn't part of the project schema. Another weird error - but I take it as you got it working in the end? For future reference, could you paste in what code you ended up with for task creation? Link to comment Share on other sites More sharing options...
pritchardhobe Posted February 8, 2017 Author Report Share Posted February 8, 2017 Sure thing! //Create the initial task that will host all sub tasks. This is tied to the main project function createParentTask(task, project, type) { var taskObj = { context_type: "task", name: task, parent_id: "56c81bf8-ee28-11e6-b31d-0a580a280613", project: project, object_type_id: "c84ec37e-d787-11e6-9d0c-0a580a280613", bid: 0, priority_id: $scope.selectedPriority.priority_id, status_id: "29c8fb88-62c2-11e5-a7f9-42010af0e994", type_id: $scope.projectTypes[type].type_id } return session.create("Task", taskObj); } function createTask(task, project, rootTask) { var taskObj = { context_type: "task", name: task, parent_id: rootTask.id, project: project, object_type_id: "11c137c0-ee7e-4f9c-91c5-8c77cec22b2c", bid: 0, priority_id: $scope.selectedPriority.priority_id, status_id: "29c8fb88-62c2-11e5-a7f9-42010af0e994", type_id: "44dbfca2-4164-11df-9218-0019bb4983d8" } return session.create("Task", taskObj); } Link to comment Share on other sites More sharing options...
Mattias Lagergren Posted February 17, 2017 Report Share Posted February 17, 2017 We've just merged a fix for the confusing error message. From now on you will get this error: "Cannot set relationship to string value." rather than content:"'unicode' object has no attribute '_sa_instance_state'" Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.