0
Hi,

Please help to achieve below scenario.

I have created one request in one of my application in serena. I have added multiple file attachments to this request.
Now I need to create a sub request from this request in the same application. I have achieved his through sub task transition. However I need to post all attachments to new sub request automatically after transition happened.
I know this direct mapping is not available. So I have created below script and added as post transition action.
While performing transition, script is executing without any error, but the attachments are not getting posted to new request. Please let me know what is wrong with my script and how to achieve this.

Script:

dim OriginalRequestId, NewRecordTS_ID
dim NewAttachment, AuthID, Type, Title, Contents, SRCTABLEID, FILENAME, ACCESSTYPE, subType, output

NewRecordTS_ID = Shell.Item.GetId()
Call Shell.Item.GetFieldValue ("ORIGINATING_WORK_REQUEST", OriginalRequestId)

Set sysRec = Ext.CreateAppRecordList(Ext.TableID("TS_ATTACHMENTS"))

whereClause = " ts_type = 16 AND TS_SRCTABLEID = 1028 AND ts_caseid = "& OriginalRequestId

If sysRec.ReadWithWhere(whereClause) Then
Call Ext.LogErrorMsg("First "+whereClause)

For Each rec in sysRec

set NewAttachment = Ext.CreateAppRecord(Ext.TableId("TS_ATTACHMENTS"))
call rec.GetFieldValue ("TS_AUTHORID", AuthID)
call rec.GetFieldValue ("TS_TYPE", Type)
call rec.GetFieldValue ("TS_TITLE", Title)
call rec.GetFieldValue ("TS_CONTENTS", Contents)
call rec.GetFieldValue ("TS_SRCTABLEID", SRCTABLEID)

call NewAttachment.SetFieldValue("CASEID", NewRecordTS_ID)
call NewAttachment.SetFieldValue("TS_AUTHORID",AuthID)
call NewAttachment.SetFieldValue("TS_TIME",Ext.DateToDBLong(now))
call NewAttachment.SetFieldValue("TS_TYPE",Type)
call NewAttachment.SetFieldValue("TS_TITLE",Title)
call NewAttachment.SetFieldValue("TS_CONTENTS",Contents)
call NewAttachment.SetFieldValue("TS_SRCTABLEID",SRCTABLEID)

output = NewAttachment.Add()
If output = 0 Then
Call Ext.LogErrorMsg("Error copying attachement")
End If
Next
End If
Like

Location [ View Larger Map ]

Responses (2)
  • Accepted Answer

    Friday, August 28 2015, 07:25 AM - #Permalink
    0
    I haven't looked at your script yet, but you would need to run this script on an action that runs after the submit of the subtask item (it can be on a hidden transition that the submit actions). Then the subtask item will exist and the parent item will not be locked.
    The reply is currently minimized Show
  • Accepted Answer

    Friday, August 28 2015, 09:38 AM - #Permalink
    0
    A different option would be to embed a report in subtask pointing back to the master record and include attachments in the report. Then anyone viewing the subtask would see a list of attachments on the main record.

    It would avoid the messiness of trying to parse out the attachment table, plus it would stay correct if someone edited the attachments on the main project.

    I don't believe a transition event is triggered on editing attachments, so someone could delete attachments on the main record and you would have no way of catching it and updating the subtask (plus the code would be very tricky to find the added/removed attachment).
    Like
    • David Berner
      more than a month ago
      I have been running into the same problem and this seems to be a great solution to me.
      Thanks!
    • Ryan Spradlin
      more than a month ago
      We do this in many scenarios and it is better because (as Roger said) it preserves the integrity of changes moving forward.
    The reply is currently minimized Show
Your Reply

Recent Tweets