Jump to content

Issue with task creation - Javascript API


pritchardhobe

Recommended Posts

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

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

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

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.

 

  1. "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"."
  2. exception:"ValueError"
Link to comment
Share on other sites

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

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

  • 2 weeks later...

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...