Fusion Manage Forum
Welcome to Autodesk’s Fusion Manage (formerly Fusion 360 Manage) Forum. Share your knowledge, ask questions, and explore popular Fusion Manage topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Adding Linked Items to Project Management via Script

2 REPLIES 2
SOLVED
Reply
Message 1 of 3
rsbishop
569 Views, 2 Replies

Adding Linked Items to Project Management via Script

Hello,

 

I'm having some problems adding a linked item to the Project Management tab via a script.  I have the relationship set up properly and I'm able to add them manually. 

 

Here's the line of code that should be adding the linked item:

 

item.project.addTask(mechItem);

 

mechItem is defined earlier in the code and successfully finds the workspace record.

 

This is the error that is thrown:

com.dms.scripting.exceptions.ScriptModelException: Could not save new tasks: []

 

Any ideas?  Thanks!

2 REPLIES 2
Message 2 of 3
D3GoTeam
in reply to: rsbishop

For Linked Items in a Project tab, you first need to create the Item.

There should be a createNewItem Library Script that has some instructions on how to call it.

 

Then once your new items is created you can add it to your project.

 

Here is an example:

Remember to import the CreateNewItem library script.

 

var prjItem = null;
var newItemProps = []; //Array of Properties for your new Linked Item

var _start = new Date();//Today
var _duration = 3;//Days
var _end = new Date(_start.getTime() + _duration*24*60*60*1000);//Add _duration to _start

//TODO: Change this to match the system name of your task worksapce
var taskWSName = 'WS_PROJECT_TASKS';

//Build the array of Field Names for your new Item newItemProps.NAME = 'Some New Name'; newItemProps.DESCRIPTION = 'Some Description'; newItemProps.START_DATE = _start; newItemProps.END_DATE = _end; newItemProps.SOME_OTHER_FIELD = 'Some Value'; //TODO: Add any other fields you want to set on your new Lined //Create the new Linked Item prjItem = createNewItem(taskWSName, newItemProps); item.project.addTask(prjItem , _start, _end, '0');

//Once you create and add your Task (prjItem) you can add Milestones to it or other info,
//but I'd put that in an OnCreate script vs. this one.
DataWorks Support
Message 3 of 3
rsbishop
in reply to: rsbishop

I ended up solving the problem.  The script was looping through items and attempted to add the same item to project management twice.  I added some logic to ensure it only tries to add each item once and it works as intended now.

 

Thanks

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report