Fusion Manage Forum
Welcome to Autodesk’s Fusion Manage (formerly Fusion 360 Manage) Forum. Share your knowledge, ask questions, and explore popular Fusion Manage topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Changing grid of workflowItem

14 REPLIES 14
Reply
Message 1 of 15
dkeeley
654 Views, 14 Replies

Changing grid of workflowItem

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.

14 REPLIES 14
Message 2 of 15
bastien.mazeran
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

Technical Support Specialist

Message 3 of 15
dkeeley
in reply to: bastien.mazeran

Hi. Thanks for the reply.

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

David.
Message 4 of 15
bastien.mazeran
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

Technical Support Specialist

Message 5 of 15
dkeeley
in reply to: bastien.mazeran

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.

Message 6 of 15
bastien.mazeran
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

Technical Support Specialist

Message 7 of 15
dkeeley
in reply to: bastien.mazeran

Hi Bartien,

 

That's perfect. Its working now.

 

Thanks for the help.

 

David.

Message 8 of 15
dkeeley
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.

Message 9 of 15
bastien.mazeran
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

Technical Support Specialist

Message 10 of 15
dkeeley
in reply to: bastien.mazeran

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...";

}

Message 11 of 15
jpiggee
in reply to: dkeeley

David,

 

What results do you get if you reset the variables, between writing to's, using the first example (i.e. separating the item update from the grid update)?

Joseph Piggee
Fusion 360 Administrator
TPI Composites
jpiggee@tpicomposites.com
Message 12 of 15
dkeeley
in reply to: jpiggee

Hi Joe,

 

I already tried that. Same error.

 

David.

Message 13 of 15
bastien.mazeran
in reply to: dkeeley

Hi David,

Please try to disable the behavior script that runs when item is modified in your technical specifications workspace and let me know if that helps.



Bastien Mazeran

Technical Support Specialist

Message 14 of 15
dkeeley
in reply to: bastien.mazeran

Hi Bastien,

 

If I disable the edit behaviour script on the workflowItem then the script runs as expected.

 

Is there a workaround for this bug or a an imminent fix? I need to use the edit behaviour script on the workflowItem also.

 

David.

Message 15 of 15
bastien.mazeran
in reply to: dkeeley

Hi David,

Let me find out for you. I will send you a separate email once I have a date.

Thank you.



Bastien Mazeran

Technical Support Specialist

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums