How to count number of times field changes in project and project task?

Jared Wason
Tera Guru

Hi,

I am trying to track the number of times the planned end date changes. I have created a field called u_planned_end_date_changes (integer) on the Project form, and a business rule (on Project) that increase the count each time planned_end_date changes. This part works, however I want the count to increase when the planned_end_date is changed via a project task as well since the project tasks dictate the projects actual end date. I tried creating a business rule (on Project Task) that essentially does "++current.parent.u_planned_end_date_changes;". That is not working though. Can anyone tell me or point me in the direction of how I should be increasing this count on project when the planned end date changes from a project task?

Thank you

1 ACCEPTED SOLUTION

It should be current.field_name++;

If you're running "AFTER" business rules you need to do current.update();

You also can't update a field on a parent record without doing a query. If you change a field like: current.parent.field = value, it won't update without doing a Gliderecord query.

View solution in original post

7 REPLIES 7

Elijah Aromola
Mega Sage

That is basically what you would do though. You would have a business rule on that table that updates that field. Can you provide your business rule, table/fields names?

The tables I am working with are pm_project and pm_project_task. The two fields I am working with are end_date (Planned end date) and u_planned_end_date_changes. I have u_planned_end_date_changes on the pm_project table. Here are my two business rules, the one for pm_project works but pm_project_task does not.

Thank you for all your help!

find_real_file.pngfind_real_file.pngfind_real_file.pngfind_real_file.png

It should be current.field_name++;

If you're running "AFTER" business rules you need to do current.update();

You also can't update a field on a parent record without doing a query. If you change a field like: current.parent.field = value, it won't update without doing a Gliderecord query.

Thanks again for your help! Doing the GlideRecord query is what solved my issue.

For anyone looking at this in the future, here is what my BR ended up being on the pm_project_task table:

(function executeRule(current, previous /*null when async*/) {
	var gr = new GlideRecord("pm_project");
	  gr.get(current.parent);
	  gr.u_planned_end_date_changes++;
	  gr.update();
})(current, previous);