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: 

Accessing Linked Items

8 REPLIES 8
SOLVED
Reply
Message 1 of 9
aaron.orange
563 Views, 8 Replies

Accessing Linked Items

Hello,

 

I am trying to delete a linked/affected item if it goes to my cancel state.  I see that there are 2 fucntions on the wiki help but no examples on how to use them.  Has anyone used or have examples of how to use these two functions?

 

item.workflowItems[i].clear()

item.workflowItems[i].remove()

8 REPLIES 8
Message 2 of 9
liumi
in reply to: aaron.orange

If all the managed (linked) items need to be deleted, you can use this:

   

 item.workflowItems.clear();

 which is equivalent to

for (var i in item.workflowItems) {
    item.workflowItems[i].remove();
}

 

If you only want to delete any particular managed items based on your condition, you could do something like this:

for (var i in item.workflowItems) {
    if (YOUR CONDITION) {
        item.workflowItems[i].remove();
    }
}

 



Michal Liu
Software Engineer
Product Lifecycle Management
Autodesk, Inc.

Message 3 of 9
aaron.orange
in reply to: liumi

HI and thanks for the reply.  When i run the  item.workflowItems.clear(); it doesnt error out but when i return to my revisoning workspace to see if the item has been deleted, it is still there.  When i attempt to run the equalivent code, it get the warning that the field "remove" doesnt exist in target workspace which is what i was getting when i intially attempted to use this.  Any suggestions?

Message 4 of 9
liumi
in reply to: aaron.orange

Sounds like you are trying to delete the item instead of removing it from Linked Item's tab?
The both functions only remove the linked items from Linked Item's tab. They do not delete those items from their workspace.

If it is not your situation, could you provide some more details? For example, how the script is triggered, from which item?


Michal Liu
Software Engineer
Product Lifecycle Management
Autodesk, Inc.

Message 5 of 9
aaron.orange
in reply to: liumi

Hi,

 

I am not trying to delete the items from the workspace.  The item(s) are in a revsioisning workspace that link to the Items and BOMS workspace. When the user moves the ECO to a "CANCELLED" state, i would like to remove the items from the Linked ITEMS tab automatically opposed to the user having to go back into the tab an manully remove the items so they can used later.

Message 6 of 9
liumi
in reply to: aaron.orange

Here are the steps I created to reproduce the issue:

1. Create an item X in ECO which is a revisioning workspace.

2. Under X's linked Items tab, there are ten items linked from the workspace of "Items and BOMs".

3. In the ECO's workflow, there is a state called "CANCELLED".

4. Attach an "Action Script" to the transition to state "CANCELLED".

5. The content of "Action Script" is

item.workflowItems.clear();

6. Under X's "Workflow Actions" tab, the transition to state "CANCELLED" is performed so above action script is triggered.

7. The web page is refreshed; if go to X's linked item's tab, there are no items there, all the ten items are deleted.

 

Could you confirm if my steps correctly replicate your situation (but only the final result is different)? Thanks!



Michal Liu
Software Engineer
Product Lifecycle Management
Autodesk, Inc.

Message 7 of 9
JHGRedekop
in reply to: aaron.orange

item.workflowItems[i].remove() will remove the item #i from the workflow item list on your original item, but leave the others in place. It won't affect the workflow item itself, though.

 

item.workflowItems[i].clear() is not a valid function -- what you want is item.workflowItems.clear(), which will remove all of the items from the workflow item list.

 

If you have an item A in workspace WS_A, which has workflow items [ B1, B2, B3, B4 ] in WS_B, then item.workflowItems[2].remove() will change item A's workflow item list to [ B1, B3, B4 ], but WS_B will be unchanged (B2 will still exist, it just won't be in A's workflow items list). item.workflowItems.clear() will empty item A's workflow item list, but again, WS_B will be unchanged.

 

The "Field remove does not exist in the target workspace. This may be an error." message you are getting when testing item.workflowItems[i].remove() is actually a bug; that message should not be appearing for valid functions.

Message 8 of 9
jared.sund
in reply to: JHGRedekop

Tested action script containing:  item.workflowItems.clear();  to remove all Affected Items from an ECO on transition to Canceled state and found it to work as expected.  Validated with Aaron and is working fine.  

Jared Sund
Sr. Product Line Manager, Product Lifecycle Management
Autodesk, Inc.
Message 9 of 9
liumi
in reply to: aaron.orange

Since you pointed that you can see the warning, I guess you might "ran" the script in the script editor page, because the warning shows up when the script is tested in the editor page. Test a script won't cause an actual run, so nothing will be changed when a script gets tested in the script editor page. 



Michal Liu
Software Engineer
Product Lifecycle Management
Autodesk, Inc.

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

Post to forums  

Autodesk Design & Make Report