It's all about the answers!

Ask a question

Calculated value script not triggering on csv import for work item creation

Jared Yeates (132) | asked Oct 31 '23, 3:56 p.m.

I have created a calculated value script that works as expected when any dependent attribute changes for a work item. However, this script is not being triggered when using a csv for importing a work item set for both creating a new work item or updating a work item attribute (which you think would trigger a save...). This is a big problem as our teams use csv imports quite often for both updating and creating new items. How can I get the script to trigger for csv imports so that it is not strictly limited to manual updates.

Accepted answer

permanent link
Ralph Schoon (63.0k33645) | answered Nov 01 '23, 6:02 a.m.

 To my knowledge, attribute customization only works in the Web UI and in the EWM Eclipse client. The attribute customization scripts are not run in other contexts e.g. when adding and modifying work items using

  • The plain Java client Libraries
  • The OSLC API
  • Automation such as CSV import
It is possible to create automation that does run in all of these contexts. This would require server extensions such as follow up actions. Caveat here is that a follow up action would only run AFTER the user saves the work item. It is technically possible to create custom editor presentations, but the effort is quite high.

Jared Yeates selected this answer as the correct answer

Jared Yeates commented Nov 01 '23, 9:09 a.m. | edited Nov 01 '23, 9:09 a.m.

So then even with a server extension it would still require the user to save the work item through Eclipse or the Web client? Or can a work item be saved through the Java client Libraries or the OSLC API to trigger the follow up action. I am guessing it would be rather hard to do this specifically for the CSV import but I might be able to make do if a follow up action can be triggered through an API interaction. 

Ralph Schoon commented Nov 01 '23, 9:49 a.m. | edited Nov 01 '23, 9:52 a.m.

Attribute customization interacts with the UI. The user enters a value, the calculated value triggers the calculated value is updated in the UI. If there is no UI happening (e.g. API call, CSV import), the JavaScript is never called and does not work. 

Contrary, follow up actions do not have access to the UI. They get triggered after the user pressed the save button. A follow up action can then participate in the save and work on the available data. This can be the update to a work item attribute. In the UI, the user would see the work item update after the save - worst case with a link to refresh.

I wanted to make sure you understand the difference.

A follow up action/participant deployed to the server would always work on a work item save and would work with API updates and CSV import as well as with changes in the UI.

But it would work differently for the user. I can not decide if that matters to your use case.

Please also note that a Server extension requires physical access to the server to deploy it. This could be impossible in cloud hosted environments.

Ralph Schoon commented Nov 01 '23, 11:30 a.m.

Instead of 

They get triggered after the user pressed the save button. 

I should have written that server side follow up actions get triggered by anything that causes the operation they guard. Does not matter what. User, API, Integrations...

Your answer

Register or to post your answer.