Hello,
I am attempting to write a script to both manual and linked tasks to the project management tab. The manual task works fine, however I cannot get the linked task to work. My code is the following:
var today = new Date();
var threedays = new Date();
var eightdays = new Date();
threedays.setDate(today.getDate() + 3);
eightdays.setDate(today.getDate() + 8);
item.project.addTask('Parts reviewed in PLM', today, threedays, '0');
var Task1 = createItem('WS_COC_TASKS');
Task1.TASK_TYPE = 'Engineering';
Task1.TITLE = 'Engineering for So# ' + item.SO_NUMBER;
Task1.DESCRIPTION = Task1.TITLE;
Task1.START_DATE = threedays;
Task1.DUE_DATE = eightdays;
Task1.STATUS = '1 - On Track';
item.project.addTask(Task1);
When I test the script it is fine, however when it is actually run, I get the following error message:
com.dms.scripting.exceptions.ScriptModelException: Could not save new tasks: []
Can someone advise me as to what I am doing wrong?
Thanks!
Task1 is a new created item which has not been saved, so it cannot be added into project management tab. Presently a new created item cannot be added into project management tab. Please expect this become feasible in the future update. Now you may have to use 2 scripts to approache this: one is used to create the task, and the other one is used to add that task.
Hi Eric,
This is what I have done for other customers in the past.
From the Project Management WS A, I will spawn a new records Task WS B.
Once the spawn is complete, it will link back to the Project Management WS A - project management tab.
You will need to run 2 scripts.
First script will be store in the library - createNewItem.
function createNewItem(baseItemName, newItemProperties){
newItem = createItem(baseItemName);
for(var propKey in newItemProperties){
newItem[propKey] = newItemProperties[propKey];
}
return newItem;
}
Second script will be action script that calls the library - SpawnTask_ProjectManagement
if(item.SPAWN_TASK_WS !== null){
var newProperties = [];
newProperties.PROJECT_LINK = item.descriptor.descriptor;
createNewItem('WS_PM1_TASK_MANAGEMENT', newProperties);
if(newItem !== null){
item.SPAWNED_TASK_LINK = newItem;
}
}
Also the trick is to have the milestone populated upon creation of the spawn records.
This way when you link back to the project management tab, it will carry over all the information.
See Attachment for References
Thanks,
Trung