In PLM 360 workflows you can trigger a script to spawn an item in a different workspace, which is great. And we can get normal properties spawning from one workspace into another, i.e. Company, User.
However, is there a way of adding code to allow you to spawn a grid on an item in one workspace, to a grid in a new item in a different workspace?
I.e. From here:
To here:
Thanks in advance.
Michael,
Yes it is possible to spawn or transfer information between workspace grids, Managed Items, PM tabs etc.
The biggest issue is understanding when those areas are available to the script engine.
I.E. - When you spawn a new workspace record from another using the CreateItem method you can only pass through the CreateItem properties for the item details tab. The other tabs are not available until after the new workspace record is fully created which does not happen until after the script or nested scripts that initiated the CreateItem method complete succesfully.
How-ever you can take advantage of triggering action scripts on the new records by using the on create, edit or initial workflow transition behaviors to trigger additional scripts to create the other tabs in the new records.
The key is to create fields on the item details to hold the information or record pointers (dmsID etc.) that are read and acted on by the secondary scripts. Three items of note for this:
1. You have to be very careful to prevent run-away scripts and if you have a lot of rows to transfer you could run into script time outs
2. I have been told by Autodesk that the WF initial transition Action script may get phased out in the future. So I use this method sparingly but unfortunately it is the best and easiest method to ensure the other tabs are available for your processing scripts on the grid tab.
3. To work around not using the initial transition I have proccessed the grid creation in two steps (either workflow or item edit)
Example:
Workspace A:
1. Fill out and create the grid rows
2. Transition the workflow (using validation on the grid if needed) to trigger spawing of the record in Workspace B (remember to create a place in both records to store references to each other).
3. Use either item details or a second workflow transition to copy the grid rows to the other workspace.
This method works better if you use the initial transition because you can have the spawing and grid row create in one step by the user, but you go with what fits your workflow.
Hope this helps.
Bob Donovan
Bigge Power Constructors
Michael,
You would want to use something like this:
for(var index in newGrid){
var oldRow = newGrid[index];
{
var newRow = item.WORKSPACE.grid.addRow();
newRow.ITEM = oldRow.ITEM;
}
}
This will copy all the rows from a grid in workspace A and move them to workspace B.