Announcements

Starting in December, we will archive content from the community that is 10 years and older. This FAQ provides more information.

Hyperlink not visible when cloning from a workspace

martin.garneau
Participant
Participant

Hyperlink not visible when cloning from a workspace

martin.garneau
Participant
Participant

Here is my issue. We have a Workspace A, which we are creating PROJECTS and a Workspace B where we have our ITEMS.

From the Project workspace we are running a script to create an ITEM which is locate in the Item workspace

When doing this, we can see the associated Item that was created in the Project workspace as an hyperlink. 

 

My problem is when we are adding new ITEM to this same PROJECT by using the Cloned function from the ITEM workspace, we cant see the hyperlink in the Project workspace, However we can see the Project hyperlink from the Item workspace.

Is their a way to get the hyperlink into the PROJECT workspace when using the clone? below is our scritp for the clone item. 

 

/*
functionality: Creates a new item with the passed properties
input : baseItemName(string) - WorkSpace ID for the new item
: newItemProperties(associative array) -- Key(string) = New Item Field ID, Value = Field's value
return :
example :
var newProperties = new Array();
newProperties['TITLE'] = "This is an eample;
newProperties['QTY'] = 5;

createNewItem('WS_NAME', newProperties);
*/

function createNewItem(baseItemName, newItemProperties){

newItem = createItem(baseItemName);

for(var propKey in newItemProperties){
newItem[propKey] = newItemProperties[propKey];
}

return newItem;
}

 

I tried adding the below which was not successful : 

//Add Item to NPD Related Items
if (item.ASSOCIATED_NPD !== null){
var npdRecord = item.ASSOCIATED_NPD;
npdRecord.relationships.addRelated(item, 'Cross-Reference', 'Unidirectional', 'Item');
}

 

0 Likes
Reply
918 Views
8 Replies
Replies (8)

philipfrench
Collaborator
Collaborator
Have you tried changing Unidirectional to Bidireçional, in your script?
Does that gve you what you need?
0 Likes

martin.garneau
Participant
Participant

Tks for the reply. I just tried and it still do not create the link of the Item into the Project Workspace for this cloned item.

 

Any other suggestions?

Thanks

 

 

0 Likes

sven.dickmans
Autodesk
Autodesk

I assume that you connect PROJECT and ITEM using the Relationships tab, correct? Do you use bi-directional relationships?

 

I just tried out your use case in my env: When I clone an ITEM which is linked to PROJECT in the relationships tab, the new ITEM clone will also be shown in the relationships tab of a PROJECT.

 

I guess that there is an onCreate script for the ITEM workspace. Does this script maybe change the relationships?

0 Likes

martin.garneau
Participant
Participant

Yes what you test is correct and i also see the project in the ITEM. My problem is if I go in the PROJECT workspace, i cant see the cloned items. I can only see the item that was created from the PROJECT workspace, which create some confusion, as we hvae a team working only from the Project workspace and need to also see all item related to this projects.

 

Im not really sure about the relationship but below are our 3 scripts we have for item creating and clone

 

CREATE ITEM script is as per below - FROM THE PROJECT WORKSPACE

//Initialize Variables
var newProperties = [];

//Create new Item
newProperties.PRODUCT_NAME = item.PROJECT_NAME;
newProperties.PRODUCT_CATEGORY = item.PRODUCT_CATEGORY;
nnewProperties.BRAND_NAME = item.BRAND_NAME;
newProperties.SUPPLIER = item.SUPPLIER;
newProperties.PROJECT_ENGINEER = item.PROJECT_ENGINEER;
newProperties.PRODUCT_MANAGER = item.PRODUCT_MANAGER;
newProperties.NPD_DMSID = item.NPD_DMSID;
newProperties.ASSOCIATED_NPD = item;

var newItem = createNewItem("WS_ITEMS", newProperties);
item.ASSOCIATED_ITEMS.add(newItem);

 

Item_On_Create script is below. - FROM THE ITEM WORKSPACE

//Create UPC Code
if (item.NUMBER !== null && item.NUMBER !== item.CURRENTITEMNUMBER){
item.UPC_CODE = createUPC(item.NUMBER);
item.CURRENTITEMNUMBER = item.NUMBER;
}

//Add Item to NPD Related Items
if (item.ASSOCIATED_NPD !== null){
var npdRecord = item.ASSOCIATED_NPD;
npdRecord.relationships.addRelated(item, 'Cross-Reference', 'Unidirectional', 'Item');
}

//Record Original DMSID
item.ORIG_DMSID = item.master.dmsID;

 

 

Our createNewItem script (cloned) is as per below - From ITEM Workspace

/*
functionality: Creates a new item with the passed properties
input : baseItemName(string) - WorkSpace ID for the new item
: newItemProperties(associative array) -- Key(string) = New Item Field ID, Value = Field's value
return :
example :
var newProperties = new Array();
newProperties['TITLE'] = "This is an eample;
newProperties['QTY'] = 5;

createNewItem('WS_NAME', newProperties);
*/

function createNewItem(baseItemName, newItemProperties){

newItem = createItem(baseItemName);

for(var propKey in newItemProperties){
newItem[propKey] = newItemProperties[propKey];
}

return newItem;
}

 

Hope this can help

Thanks

0 Likes

sven.dickmans
Autodesk
Autodesk

Thank you for sharing the scripts, this helps a lot.

From the scripts, I can see that your ITEM has a field "ASSOCIATED_NPD" which refers to the related PROJECT. The create event of the ITEM will validate if a project is defined in this given field (no matter if the item is being cloned or created by the project). If a PROJECT is set in this field, then the PROJECT will be connected to the ITEM. All seems to be set up properly and this use case is working fine on my side.

 

How do you create the clone of the ITEM, do you use the standard Clone feature of FLC or do you use a custom script to do so? Does this new clone show the given PROJECT in field ASSOCIATED_NPD?

 

0 Likes

martin.garneau
Participant
Participant

Tks for your reply.

yes We can see the hyperlink for the associated Project in the Item when we clone it and if we do a search by project, we can see the item as well since those are linked.

 

The problem we cant see the Associated Item in the Project itself. We can only see item created within the Project workspace. Once the 1 item is created and if we want to clone it vs creating new item to save some time, we need to go in the ITEM workspace, and clone it. But this wont bring the hyperlink in the PROJECT workspace and only the 1st item will be visible

 

I listed out our 3 script above that we have. 

- Item_On_Create : Item creation from the Project workspace

- Create Item: Item creation from the Item workspace ( We don't use it as we cant assign a project to )

- CreateNewItem: Item clone from the Item workspace

 

Hope this help

tks

0 Likes

sven.dickmans
Autodesk
Autodesk

I understand the problem, but I do not understand why the use case does not work as expected. Based on what you described, all seems to be fine. Can you please verify that the script Item_On_Create is attached to the create event of your ITEM workspace (see the Behaviors utility within the Workspace Manager)?

 

Btw, the "createNewItem script (cloned)" does not do anything it all as the function call (createNewItem('WS_NAME', newProperties);) is within the comments section (before '*/');

0 Likes

martin.garneau
Participant
Participant

I just looked at the Behavior in the ITEM workspace and yes the "Item_On_Create" is there.

 

I also looked into the NDP workspace and the "Create items" script  is there. Should we have the Cloned item script out there? so it create the hyperlink?

 

Thanks

0 Likes