How do I update a parent field when subtask field changes?

dfilkins's picture
dfilkins asked on March 30, 2011 - 5:34pm | Replies (4).

I'm needing to set the value of a single-select field that is shared/same between a parent and subtask.

When the field value of the subtask changes, I would like to populate the same field on the parent with the same value of the subtask.

Is there a way a TeamScript can identify the associated parent of a subtask AND set the parent's field value when that same field changes in the subtask? Any ideas?

4 Answers

Nikolay Ruban's picture

use the search for word subtask.

dfilkins's picture
dfilkins replied on March 31, 2011 - 12:10pm.

Thank you Nikolay. I assume there is documentation in the TeamScript manual that refers to this "Search" function/feature you're suggesting.

Anonymous's picture
Anonymous replied on September 13, 2011 - 8:41pm.

I did something similar in which comments added to a subtask were copied back to the parent.

You need a field on the subtask that holds the id of the parent.

sub copyCommentsToParent(item, table_id)
dim t_comment, p_comment, parent_id, parent, ok

ok = item.getFieldValue("Comments", t_comment)
ok = item.getFieldValue("Parent", parent_id)

if (parent_id <> 0) then
set parent = ext.createProjectBasedRecord(table_id)
ok = parent.read(parent_id)
ok = parent.getFieldValue("Comments", p_comment)
ok = parent.setFieldValue("Comments", t_comment & vbcrlf & vbcrlf & p_comment)
ok = parent.updatewithlock(true)
end if
end sub

CMCrossroads is a TechWell community.

Through conferences, training, consulting, and online resources, TechWell helps you develop and deliver great software every day.