Skip to content

Instantly share code, notes, and snippets.

@gsherman
Created October 31, 2012 15:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gsherman/3987865 to your computer and use it in GitHub Desktop.
Save gsherman/3987865 to your computer and use it in GitHub Desktop.
When deleting a communication object, delete any related time bombs
Sub Form_Load()
Me.DoDefault
End Sub
Sub cmdDelete_Click()
'When deleting a communication object, delete any related time bombs
'Hopefully we can get it deleted before rulemanager picks it up
'
'The other way we could approach this is to NOT do Me.DoDefault here,
'and instead just copy the baseline CB code into here, so we can do the delete
'communication and delete time_bomb in the same transaction
'If using that approach, make sure we use the CB code from the correct version of Clarify
'
Dim selCommViewRecord As Record
If gridCommunication.GetSelected(selCommViewRecord) = False Then
Exit Sub
End If
Dim commId As Long
commId = selCommViewRecord.GetField("objid")
Me.DoDefault
Dim br As New bulkRetrieve
br.SimpleQuery 0, "communication"
br.AppendFilter 0, "objid", cbEqual, commId
br.RetrieveRecords
Dim commRecordList As List
Set commRecordList = br.GetRecordList(0)
'If the communication object still exists, then the Delete didn't happen
If commRecordList.Count <> 0 Then Exit Sub
br.Clear
br.SimpleQuery 0, "time_bomb"
br.AppendFilter 0, "focus_lowid", cbEqual, commId
br.AppendFilter 0, "focus_type", cbEqual, 5208 'communication
br.RetrieveRecords
Dim timeBombList As List
Set timeBombList = br.GetRecordList(0)
'If there are no time_bombs found, then there's nothing to do here
If timeBombList.Count = 0 Then Exit Sub
Dim cnt As Integer
Dim bs As New BulkSave
For cnt = 0 To timeBombList.Count - 1
Dim timeBombRecord As Record
Set timeBombRecord = timeBombList.ItemByIndex(cnt)
bs.DeleteRecord timeBombRecord
Next cnt
bs.Save
End Sub
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment