PLM 360 General

Reply
Distinguished Contributor
obourne
Posts: 171
Registered: ‎03-02-2011
Message 1 of 10 (249 Views)
Accepted Solution

Automated Linking of Items

249 Views, 9 Replies
02-07-2013 04:08 PM

I'd like to have a script (or something) link two items. Here is my scenario:

 

I have a revision controlling workspace item. In the item details tab I will choose an item from a revision controlled workspace via a picklist. Upon saving I want that selected item to automatically be added to the linked items tab. Is there a scripting function that can do that?

Product Support
piggeej
Posts: 279
Registered: ‎03-27-2012
Message 2 of 10 (233 Views)

Re: Automated Linking of Items

02-11-2013 06:35 AM in reply to: obourne

Orrin,

 

As of this release ( 8.0) you cannot script to the linked Items tab, however this is in development and will be available on a future release.



Joe Piggee
Support Specialist
Product Support
Autodesk, Inc.

Distinguished Contributor
obourne
Posts: 171
Registered: ‎03-02-2011
Message 3 of 10 (229 Views)

Re: Automated Linking of Items

02-11-2013 07:57 AM in reply to: piggeej

Thanks for the info.

 

Is there a way script additions to the relationships tab?

Product Support
piggeej
Posts: 279
Registered: ‎03-27-2012
Message 4 of 10 (224 Views)

Re: Automated Linking of Items

02-11-2013 08:04 AM in reply to: obourne

Yes, Adding items to the relationship tab is now supported. (as of 8.0)

The Wiki will be updated shortly but here’s the basic notes on this.

 

 

 

 

The relationship tab support will follow the same basic design as grid and workflow items.

 

The features supported:

 

item.relationships -- A list of relationships

item.relationships.addRelated({ RELATED: target, TYPE: typeStr, DIRECTION: dir, DESCRIPTION: desc }) – Adds relationship to list

item.relationships.addRelated(target, typeStr, dir, desc) – Adds relationship to list

 

dir is optional, and defaults to Unidirectional. Will be bidirectional if dir is 2 or "bidirectional" (case insensitive)

desc is optional, and defaults to blank

 

item.relationships[i] has the following properties:

  item.relationships[i].id – DMS ID of target item

  item.relationships[i].descriptor – Descriptor of target item

  item.relationships[i].item – Target item

  item.relationships[i].item.FIELD – Field on target item

  item.relationships[i].type – Relationship type name

  item.relationships[i].direction – One of “Unidirectional” or “Bidirectional”

  item.relationships[i].description – Relationship type description

 

item.relationships[i].setRelationshipType(typeStr) – Sets the relationship type to “typeStr” (or throws an error if “typeStr” is not valid)

item.relationships[i].setDescription(desc) – Sets the relationship description to “desc”

item.relationships[i].remove() – Removes relationship i from the list



Joe Piggee
Support Specialist
Product Support
Autodesk, Inc.

Distinguished Contributor
obourne
Posts: 171
Registered: ‎03-02-2011
Message 5 of 10 (222 Views)

Re: Automated Linking of Items

02-11-2013 08:08 AM in reply to: piggeej

Thanks. That should help for another workflow I'm devolping.

 

What permisions are needed? I assume the logged in user credentials will be uase for the permission ergo the user must have permission to add to an items relationships tab? Is this correct?

Product Support
piggeej
Posts: 279
Registered: ‎03-27-2012
Message 6 of 10 (218 Views)

Re: Automated Linking of Items

02-11-2013 08:34 AM in reply to: obourne

Correct, If the user has the proper perrmissions for that tab, then the script will be able to write to it.



Joe Piggee
Support Specialist
Product Support
Autodesk, Inc.

Member
darren.hartenstine
Posts: 7
Registered: ‎11-13-2006
Message 7 of 10 (156 Views)

Re: Automated Linking of Items

04-02-2013 12:19 PM in reply to: piggeej

I've been trying to implement this within a script and having difficulty with formating "RELATED: target".  Would you be able to provide an example of target? 

 

item.relationships.addRelated(target, typeStr, dir, desc)

 

My goal is to evaluate a field for the customer name, and if it exists, grab the related workspace item and make a relationship.

 

Darren Hartenstine

 

 

Product Support
piggeej
Posts: 279
Registered: ‎03-27-2012
Message 8 of 10 (148 Views)

Re: Automated Linking of Items

04-02-2013 12:30 PM in reply to: darren.hartenstine

Darren,

 

Target is equal to the descriptor of the target item you wish to add, from the workspace you have predefined.

 

So an example would be:

item.relationships.addRelated(descriptor of item you want to add, type of relationship, direction of relationship, description of relationship)



Joe Piggee
Support Specialist
Product Support
Autodesk, Inc.

Member
darren.hartenstine
Posts: 7
Registered: ‎11-13-2006
Message 9 of 10 (143 Views)

Re: Automated Linking of Items

04-02-2013 01:47 PM in reply to: piggeej

Thanks Joe for the reply.  I am very new to scripting, so I appoligize for more clarification.

 

I have a workspace for managing customers and the descriptor is set to a field called "NAME".  Is this the descriptor of the Workspace you are referring to?

 

item.relationships.addRelated('Customer Name1','Cross-Reference','Bidirectional','Test');

item.relationships.addRelated('Customer Name2','Cross-Reference','Bidirectional','Test');

 

My confusion is that the workspace I am working in is different from the customer workspace.  I feel like I am formating the target wrong and it needs ID's, or something.

Product Support
mazerab
Posts: 203
Registered: ‎11-20-2012
Message 10 of 10 (131 Views)

Re: Automated Linking of Items

04-02-2013 04:00 PM in reply to: darren.hartenstine

Hi Darren,

 

You can verify the descriptor value by going through a very simple test:

 

- browse to any item that can have relationships

- locate in URL dmsID and workspaceID values 

e.g. using this URL https://mytenant.autodeskplm360.net/workspace#workspaceid=50&dmsid=20432&tab=relationship, the workspace ID is 50 and the item dmsID is 20432.

- add a new relationship to the item

- create new action script that will solely be used for testing

- edit action script to have this single line of code

 

println(item.relationships[0].descriptor);

 

Run a test after inputting the dmsID and workspace ID. This will return the descriptor string you are after.

 

I hope this helps.



Bastien Mazeran
Support Specialist
Product Support
Autodesk, Inc.

You are not logged in.

Log into access your profile, ask and answer questions, share ideas and more. Haven't signed up yet? Register

Announcements
Are you familiar with the Autodesk Expert Elites? The Expert Elite program is made up of customers that help other customers by sharing knowledge and exemplifying an engaging style of collaboration. To learn more, please visit our Expert Elite website.

Ask the Community