• Industries
  • Products
  • Buy
  • Services & Support
  • Communities
  • Discussion Groups

    Autodesk PLM 360

    Reply
    Valued Contributor
    obourne
    Posts: 121
    Registered: ‎03-02-2011
    Accepted Solution

    Automated Linking of Items

    149 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?

    Please use plain text.
    Product Support
    Posts: 156
    Registered: ‎03-27-2012

    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.

    Please use plain text.
    Valued Contributor
    obourne
    Posts: 121
    Registered: ‎03-02-2011

    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?

    Please use plain text.
    Product Support
    Posts: 156
    Registered: ‎03-27-2012

    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.

    Please use plain text.
    Valued Contributor
    obourne
    Posts: 121
    Registered: ‎03-02-2011

    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?

    Please use plain text.
    Product Support
    Posts: 156
    Registered: ‎03-27-2012

    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.

    Please use plain text.
    Member
    Posts: 6
    Registered: ‎11-13-2006

    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

     

     

    Please use plain text.
    Product Support
    Posts: 156
    Registered: ‎03-27-2012

    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.

    Please use plain text.
    Member
    Posts: 6
    Registered: ‎11-13-2006

    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.

    Please use plain text.
    Product Support
    Posts: 53
    Registered: ‎11-20-2012

    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.
    Please use plain text.