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?
Solved! Go to Solution.
Solved by jpiggee. Go to Solution.
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.
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
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?
Correct, If the user has the proper perrmissions for that tab, then the script will be able to write to it.
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
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)
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.
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.