PLM 360 General

Reply
Mentor
dkeeley
Posts: 214
Registered: ‎10-04-2012
Message 1 of 15 (176 Views)

Changing grid of workflowItem

176 Views, 14 Replies
04-22-2013 08:57 AM

Hi,

 

I am trying to change a grid value using the following script;

 

item.workflowItems[0].item.grid[0].DETAILS = 'Test';

 

The script does not seem to work. I do not seem to be able to write to the grid of a workflow item in this way. 

 

I can read the current value of the field so the script syntax is fine. Also I can change the grid value when running a script on the item itself using;

 

item.grid[0].DETAILS = 'Test';

 

Can you tell me what I am doing wrong?

 

Thanks,

 

David.

Product Support
mazerab
Posts: 203
Registered: ‎11-20-2012
Message 2 of 15 (150 Views)

Re: Changing grid of workflowItem

04-23-2013 11:16 AM in reply to: dkeeley

Hi David,

Thank you for your question.

Although I can definitely reproduce what you are experiencing, the behavior is by design. When you add a linked item to the workflow items tab of another item, you are simply establishing a link in between two records. If you wish to edit the value of the fields stored on the linked item, then it makes sense to make the edit on the source item directly and not on the linked item using the workflowItems array.

 

In short, build a bridge to the source item using the descriptor of the workflow item you are interested in editing, then write to the item with the bridge link not the workflow link.



Bastien Mazeran
Support Specialist
Product Support
Autodesk, Inc.
Mentor
dkeeley
Posts: 214
Registered: ‎10-04-2012
Message 3 of 15 (148 Views)

Re: Changing grid of workflowItem

04-23-2013 11:21 AM in reply to: mazerab
Hi. Thanks for the reply.

Can you give me an example of a bit of code that illustrates what you are describing?

David.
Product Support
mazerab
Posts: 203
Registered: ‎11-20-2012
Message 4 of 15 (140 Views)

Re: Changing grid of workflowItem

04-23-2013 01:21 PM in reply to: dkeeley

Hi David,

Could you please clarify what the use case is for needing to update the target item fields from the workflow items tab? Typically the process is done the other way around.

 

To answer your question on code example, the target item can be accessed in multiple ways:

 

- item.workflowItems[0].item (target item object)

- item.workflowItems[0].id (dmsID of target item)

- item.workflowItems[0].descriptor (descriptor of target item)

 

You should then be able to push those values elsewhere to perform the field update.

 

Additionally, I have just learnt that the ability to write from the workflow items tab will be made available via scripting in our next upcoming release in May.

 

 



Bastien Mazeran
Support Specialist
Product Support
Autodesk, Inc.
Mentor
dkeeley
Posts: 214
Registered: ‎10-04-2012
Message 5 of 15 (129 Views)

Re: Changing grid of workflowItem

04-24-2013 08:05 AM in reply to: mazerab

Hi Bastien,

 

Thanks for the reply.

 

I'm still a little confused about what you are saying here. Let me add a little more context to the discussion.

 

The use case is as follows; 

 

We are using the system to create technical specifications (revision controlled items). These items use the grid to list the customer requirements as follows;

 

Column 1: Row Number (Single Line Text)

Column 2: Specification Category (Filtered Pick List)

Column 3: Specification Details (Paragraph)

 

When a user is creating an item the following data is imported directly into the grid based on some values he has selected in the item details;

 

Column 4: Customer Preference (Paragraph)

Column 5: Import Option for Customer Preference (Yes/No Picklist)

Column 4: Country Preference (Paragraph)

Column 5: Import Option for Country Preference (Yes/No Picklist)

 

When the user is ready to release the tech spec it is attached to a revisioning item. The revisioning item is then submitted to the next state in the workflow.

 

So far so good. Everything up until this point works fine.

 

When the revisioning item is submitted some condition, validation and action scripts run. It is only a portion of the latter action script that is causing a problem (see attached - line 55 onwards). You can see that I am able to successfully write to the item details of the workflow item using the following syntax;

 

item.workflowItems[0].item.FIELD_ID

 

But I am unable to write to the grid of the same item using a similar sytax;

 

item.workflowItems[0].item.grid[0].GRID_COLUMN_FIELD_ID

 

Can you help me see what I am doing wrong?

 

Thanks,

 

David.

Product Support
mazerab
Posts: 203
Registered: ‎11-20-2012
Message 6 of 15 (126 Views)

Re: Changing grid of workflowItem

04-24-2013 11:35 AM in reply to: dkeeley

Hi David,

I apologize for the confusion. I went ahead and double checked my testing and I can actually get it to work just fine in my environment. So yes I was not testing properly and I apologize again for missing this.

 

My action script is called when the change order is transitioned. The change order has one item as affected item. This item has a linked item (through the Workflow Items tab) to yet another item with a grid. And that last item has a field defined in its grid.

 

In short, my action script does this:

 

var affectedItem = item.workflowItems[0].item; // storing the change order's affected item in a new variable

var linkedItem = affectedItem.workflowItems[0].item; //storing the change order's affected item's linked item into a separate variable

linkedItem.grid[0].GRID_FIELD = "updating wfitems grid field value...";

 

Perhaps your code does not work because you are calling the item object multiple times in the same line of code:

item.workflowItems[0].item.grid[0].GRID_COLUMN_FIELD_ID
 
Could you try to store each item object into a separate variable?


Bastien Mazeran
Support Specialist
Product Support
Autodesk, Inc.
Mentor
dkeeley
Posts: 214
Registered: ‎10-04-2012
Message 7 of 15 (115 Views)

Re: Changing grid of workflowItem

04-25-2013 07:22 AM in reply to: mazerab

Hi Bartien,

 

That's perfect. Its working now.

 

Thanks for the help.

 

David.

Mentor
dkeeley
Posts: 214
Registered: ‎10-04-2012
Message 8 of 15 (108 Views)

Re: Changing grid of workflowItem

04-25-2013 09:38 AM in reply to: dkeeley

Hi Bastien,

 

I am still having a problem with the script. When I try to update the grid and the item details of the workflowItem at the same time (i.e. in the same script) then it only updates the item details. The grid does not update.

 

var linked_item = item.workflowItems[0].item;
linked_item.grid[0].GRID_FIELD_ID= 'Script has worked';
linked_item.FIELD_ID = 'Script has worked';

 

If I remove the line of script that updates the item details then grid updates.

 

var linked_item = item.workflowItems[0].item;
linked_item.grid[0].GRID_FIELD_ID= 'Script has worked';
//linked_item.FIELD_ID = 'Script has worked';

 

Can you tell me if you see the same problem? Am I doing something wrong?

 

David.

Product Support
mazerab
Posts: 203
Registered: ‎11-20-2012
Message 9 of 15 (101 Views)

Re: Changing grid of workflowItem

04-25-2013 03:10 PM in reply to: dkeeley

Hi David,

 

This is odd as I have it working in my environment. I can update both the item details field and grid field in same operation. I have emailed you separately the code I have used while testing.



Bastien Mazeran
Support Specialist
Product Support
Autodesk, Inc.
Mentor
dkeeley
Posts: 214
Registered: ‎10-04-2012
Message 10 of 15 (98 Views)

Re: Changing grid of workflowItem

04-25-2013 03:48 PM in reply to: mazerab

Hi Bastien,

 

I modified my code to look a little bit more like yours. However I still have exactly the same problem.

 

When the code is as shown below only the item details field is updated;

 

var wfItems = item.workflowItems;

for (var index in wfItems){

var linkedItem = item.workflowItems[index].item;
var index2 = 0;

linkedItem.SUBMITTED_BY = 'updated value...';
linkedItem.grid[index2].DETAILS = "updated value...";

}

 

When the code is as shown below only the grid field is updated;

 

var wfItems = item.workflowItems;

for (var index in wfItems){

var linkedItem = item.workflowItems[index].item;
var index2 = 0;

//linkedItem.SUBMITTED_BY = 'updated value...';
linkedItem.grid[index2].DETAILS = "updated value...";

}

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