cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - Your Friends List is a way to easily have access to the community members that you interact with the most! X

Store calculated Field Values to history using trigger

vikramm
7-Bedrock

Store calculated Field Values to history using trigger

I understand that we can use the existing "History Computation Fields - Daily or Weekly or Monthly" triggers to store the field values to history.

But is there a way to store the values which we compute using custom trigger to the field history ?

Example : "Requirements Count" - I can compute this metric using a trigger but is there a way to store this value to history. The use case is to create a trend chart based on the history values.

I know a static computation field with aggregate function can be created and stored to history but I see from below article that PTC recommends not to use complex functions in static computation which will hit the performance of daily metrics trigger.

https://www.ptc.com/en/support/article/CS224165?&language=en&posno=2&q=dynamic%20and%20static%20computations&source=search

Any suggestions on this topic would be helpful.

1 ACCEPTED SOLUTION

Accepted Solutions
ascott
17-Peridot
(To:vikramm)

"Requirements Count" (as defined by the ALM Solution that is a common package installed) is a regular field with the following key attributes: 1.) Never Editable (by users) 2.) Populated only by trigger.

In this case, the history is saved automatically, the same way when a user edits a (user editable) field the changes are stored.


Yours truly,

-Andrew

 

View solution in original post

3 REPLIES 3
ascott
17-Peridot
(To:vikramm)

The function you want is shown below.

If you are already using that function and don't see entries saved to history - make sure you have the "Show Computed Fields in History" enabled.

View menu > Show Computed Field in History

  • computeHistoryNow

    public void computeHistoryNow(java.lang.String fieldname)
                           throws mks.frame.triggers.TriggerException
    Compute a computed field now, and store its new value to history. The value is computed only for the current issue, i.e. the issue represented by this bean. If it is a statically computed field, update the issue record for the field as well. Note that this computation uses its own transaction. If this method does not throw an exception then the values have been successfully computed, stored, and committed. This method is therefore not permitted in a PRE trigger. It may be used either in a scheduled trigger, or in a POST trigger.
    Parameters:
    fieldname - The string name of the field to compute.
    Throws:
    mks.frame.triggers.TriggerException - If the field is not a computed field or on error computing the history for the field.
vikramm
7-Bedrock
(To:ascott)

Hi @ascott 

 

Thank you so much for your response.

I assume "ComputeHistoryNow" function can be used on fields for which the computation is defined at the field level in admin UI of PTC ILM. Correct me if I am wrong ?

 

I meant the fields like "Requirements Count" which don't have any computation defined at the field level and are calculated using DailyMetrics.js script. I don't see "ComputeHistoryNow" function used anywhere in this trigger script. But I am able to use this field in trend charts. So this means the values are getting stored in history but I am not sure how. Do you have any thoughts or inputs on this feature?

 

 

Thanks,

Vikram M

ascott
17-Peridot
(To:vikramm)

"Requirements Count" (as defined by the ALM Solution that is a common package installed) is a regular field with the following key attributes: 1.) Never Editable (by users) 2.) Populated only by trigger.

In this case, the history is saved automatically, the same way when a user edits a (user editable) field the changes are stored.


Yours truly,

-Andrew

 

Top Tags