In PLM Scripting, the built-in object under item matching the Project Management tab is Project object. An Array of Project objects will be returned by calling item.project.subTasks. They give you all the projects of the item. The item here must be an instance of Item.
Basically a project task can be divided into three classes: text task, linked task and milestone task. In scripting, all of them are represented using Project object, but there is some difference when we deal with each of them. In this post, let’s talk about what the common ground they have and what the difference between them.
Text project task
A text project task is a task not linked to any item. Its title is given by user.
var textTask = item.project.subTasks[0];
// r/w title
textTask.title = ‘new title’;// r/w start date of project
textTask.start_date = new Date();// r/w end date of project
textTask.end_date = new Date(new Date().getTime() + 24 * 60 * 60 * 1000);// r/w progress, must be in [0, 100]
textTask.progress = 50;// read duration
var duration = textTask.duration;// read owner, the parent item of the project
var owner = textTask.owner;
Linked project task
A linked project task is a task linking to an item. It also has the same properties as a text project task, however the title property will be the linked item’s descriptor instead of the text defined by the user. The linked item can be gotten via linkedTask.item.
var linkedTask = item.project.subTasks[1];
// read linked item. An Item object is returned
var linkedItem = linkedTask.item;
Milestone project task (Read-only task)
If a linked project contains milestones, then we call it a milestone project task, or a read-only project task because all the properties of it are read-only. That’s the only difference between linked task and milestone task.
Create project task
The general form to create a task is:
new Task(Title/LinkedItem[, StartDate[, EndDate[,Progress]]]);
The square brackets parts are optional. The default value for both start and end dates is today, and the default progress is 0.
Create a text task:
// create a text task
var newTextTask = new Task(‘Text Task’, new Date(), new Date(new Date().getTime() + 24 * 60 * 60 * 1000), 0);
// add task into array
item.project.subTasks.push(newTextTask);
Create a linked/read-only task:
// fetch item to be linked
var itemToBeLinked = loadItem(1234);
// create linked task, leave the rest parameters default
var newLinkedTask = new Task(itemToBeLinked);
// add new task into array
item.project.subTasks.push(newLinkedTask);
--Michal
6 Years
Today my blog turns 6, which is 110 years is binary. To celebrate, I’m going to reveal a couple of Easter Eggs that I’ve slipped in over the years. Specifically, the titles of some of my apps. One thing I love about writing my own apps is that I get to pick the name. An in two cases, I named the app in such a way as to set up a joke. That’s just the type of guy I am.
Project Thunderdome:
Yes, it’s part of a movie title, but the joke goes deeper than that. It’s probably best explained by this Mystery Science Theater 300 clip. By the way, I’m a huge MST3K fan.
The TTP Project:
This app never achieved the popularity of Thunderdome, which is a shame. I wanted to unload this joke on more people. Basically the conversation would go like this.
(me an you chatting about PLM API programming)
Me: … You should check out my sample app, The TTP Project?
You: What does TTP stand for?
Me: The TTP Project
Again, I stole this joke from another source. Because that’s also the type of guy I am.
-- Doug
Posted at 08:02 AM in Commentary | Permalink | Comments (1)
Tweet This! |