Just wondering, is it possible to manually make/add a subtask using a script? I know that you can mark the transition to 'Create a Subtask', but what I'm running into is that there will be between 5-7 subtasks with different owners, and my users do not want to manually create each one.
Good Afternoon, I create my subtasks exclusively with scripting to provide more control over a variety of variables. When creating a subtask as stated above, you need to create a record in the SUBTASK table. However, I also create records in the ATTACHMENTS table for each link (I create a two-way link for subtasks). There is a TS_TYPE field that is populated with a 'out of the box' value by Team Track for each direction of the link. To help me look at specific 'types' of links, I used different values to help me read through the attachments table when chasing a link from one record to another. The development of the create subtask script also enables me to personalize the title of the links in both records so they have meaning and fulfill user requirements as to what a user group wants to see such as "Primary to Secondary Link - <Secondary item id>" and Secondary to Primary Link - <Primary item id>".
Thank you for your response. I've got the subtask created, and necessary actions assigned. However, if I do it through the script, the Attachment Section does not show the Subtask on the user screen. Would I need to also make an addition to the TS_Attachments table as well? Here's my script: ' Script: Create Subtask ' Function: Reads in Values from parent item and creates subtasks
Dim SubmitterID, Title, Description, ServersAffected, ServerOwner, DBAffected, DBOwner, CRTitle If Ext.ShellHasProp("Item") Then Set CurrentRecord = Shell.item ItemID = Shell.Item.GetID() 'Get Master Values Call CurrentRecord.GetFieldValue("SUBMITTER", SubmitterID) Call CurrentRecord.GetFieldValue("TITLE", Title) Call CurrentRecord.GetFieldValue("DESCRIPTION", Description) Call CurrentRecord.GetFieldValue("AFFITEM1", ServersAffected) Call CurrentRecord.GetFieldValue("AFFECT1OWNER", ServerOwner) Call CurrentRecord.GetFieldValue("AFFECTITEM2", DBAffected) Call CurrentRecord.GetFieldValue("AFFECT2OWNER", DBOwner) If (ServersAffected = 1) Then CRTitle = "Action from ChangeRequest: " title 'Setup new copied record Set NewRecord = Ext.createappRecord(Ext.TableID("UAT_ACTION_TRACKER")) Call NewRecord.SetFieldValue("TITLE", CRTitle) Call NewRecord.SetFieldValue("DESCRIPTION", Description) Call NewRecord.SetFieldValue("OWNER", ServerOwner) Call NewRecord.SetFieldValue("SUBMITDATE", Now()) Call NewRecord.SetFieldValue("SUBMITTER", SubmitterID) Call NewRecord.SetFieldValue("LASTCHANGEDDATE", Now()) Call NewRecord.SetFieldValue("ACTIVEINACTIVE", 0) Call NewRecord.SetFieldValue("PROJECTID", 18) Call NewRecord.SetFieldValue("STATE", 50) 'Assigned State Call NewRecord.SetFieldValue("LASTMODIFIER", SubmitterID) Call NewRecord.SetFieldValue("LASTMODIFIEDDATE", Now()) Call NewRecord.SetFieldValue("DESCRIPTION", Description) Call NewRecord.SetFieldValue("LASTSTATECHANGER", SubmitterID) Call NewRecord.SetFieldValue("LASTSTATECHANGEDATE", Now())
NewSubtaskID = NewRecord.Add() 'Create new record in subtask table Set NewSubtaskEntry = Ext.createappRecord(Ext.TableID("TS_SUBTASKS")) Call NewSubtaskEntry.SetFieldValue("SUBTABLEID", 1002) Call NewSubtaskEntry.SetFieldValue("SUBITEMID", NewSubtaskID) Call NewSubtaskEntry.SetFieldValue("MASTERITEMID", ItemID) Call NewSubtaskEntry.SetFieldValue("MASTERTABLEID", 1054) Call NewSubtaskEntry.SetFieldValue("PROGRESS", 0) SubtaskEntryID = NewSubtaskEntry.Add() End if End If
Hi Clyde, Would it be possible for you to explain how you can personalise the title of the links. We have had a enhancement request with Serena for quite some time for the ability to create different "types" of links (ie, why 2 issues were linked together) - but I don't think that it will ever be delivered. I have started using a script to link 2 existing issues as principal/sub-task, but the link title just uses the standard link titles, so the ability to define how the link was generated would be really handy. Thanks, Dave
So I've almost got it... but need one more piece of advice/guidance, please. I've got a notification and a notification escalation. The escalation fires the script that moves a subtask if it has not been replied to in 48 hours. It closes the workflow, closes the subtask. The only thing I am trying to do is to find a way to update the TS_Progress field in TS_Subtasks, so that my primary item transitions as it should. Can anyone see why my script would not update the DB? The problem I run into is that Subtask 1, progress will update just fine to a '1'. However, Subtask 2 and 3 do not update in the DB, so Master 1 will not transition properly.
Script below (not the cleanest right now): 'Set Variables as Needed inactive = 1 nstate = 408 nowner = 0 EvalField = 3293 progressmoved = 1 numTasks = 0 ' Read the item's record and lock it Set objItem = Ext.CreateAppRecord(Shell.TableId) If objItem.Read(Shell.ItemId) AND objItem.Lock() Then Call objItem.GetFieldValue("ISSUEID", strIssueID) Call objItem.GetFieldValue("PARENTCRNUM", strParentNum) Call objItem.SetFieldValue("STATE", nState) Call objItem.SetFieldValue("OWNER", nowner) Call objItem.SetFieldValue("Reccomendation", EvalField) Call objItem.SetFieldValue("ACTIVEINACTIVE", inactive) Call objItem.SetFieldValue("LASTCHANGEDDATE", Ext.DateToDbLong(Now())) Call objItem.SetFieldValue("CLOSEDATE", Ext.DateToDbLong(Now())) If Not objItem.Update() Then Call Ext.LogWarningMsg("Update failed on item "
Good Afternoon, I wonder if your script simply needs to be updated using the correct OBJECT name when performing the update. Your script states: For Each item in SubTaskUpdate so each object you manipulate will be 'item' and not SubTaskUpdate. Try Call item.SetFieldValue("Progress",progressmoved) followed by Updatetask = item.Update() and Call item.Unlock()
Since you are not performing a "transition", your actions will not fire even if you manually update the progress field. If you are moving the subtask by TeamScripting, you will have to move the parent by TeamScripting as well. Another alternative would be to run a TeamTrack WebService on the notification instead of the TeamScript to really transition the subtask and then your actions will work. Or if you need to do other things within the TeamScript, then have the TeamScript invoke the transition by calling out to a TT Web Service or API executable.