Notifying the Yankee (part 2) This time with the Clarify Client
Recently I posted about how to notify the yankee, meaning the person who a case was yanked from.
Now, lets see how we can accomplish the same task within the Clarify Classic Client.
Most of the setup is the same as I covered previously.
4. Add the participant record
Add a Participant using ClearBasic
To add a participant record, we can add some ClearBasic code behind form 737, which is the Yank form.
Caution: this is an old-school C form, so much of the prescribed way of using CB code on this form doesn’t work. Especially around the Form_Save routines.
Here’s what I came up with:
Dim actEntryObjid As Long Function GetCurrentOwnerObjid() As Long Dim previousOwnerObjid As Long Dim lor As List Dim rec As Record Dim br As New BulkRetrieve Dim objectType As String Dim ownerRelation As String GetCurrentOwnerObjid = 0 Select Case YANK_OBJ_TYPE.Text Case "Case" objectType = "case" ownerRelation = "case_owner2user" Case "Subcase" objectType = "subcase" ownerRelation = "subc_owner2user" End Select If Len(objectType) > 0 Then br.SimpleQuery 0, objectType br.AppendFilter 0, "id_number", cbEqual, EDT_5.Text br.TraverseFromParent 1, ownerRelation, 0 br.RetrieveRecords Set lor = br.GetRecordList(1) If lor.Count > 0 Then Set rec = lor.ItemByIndex(0) previousOwnerObjid = rec.GetField("objid") End If End If GetCurrentOwnerObjid = previousOwnerObjid End Function Sub Form_Load() Me.DoDefault End Sub Sub Form_Save2(bs As BulkSave) Dim recActEntry As Record If bs.CountByType("act_entry") > 0 Then Set recActEntry = bs.GetRecordByIndex(0,"act_entry") actEntryObjid = recActEntry.GetField("objid") End If End Sub Sub SaveParticipant(previousOwnerObjid As Long) Dim recP As New Record Dim bs As New BulkSave If actEntryObjid > 0 And previousOwnerObjid > 0 Then recP.RecordType = "participant" recP.SetField "role_code", 1 bs.InsertRecord recP bs.RelateRecordsToID recP, "act_entry", actEntryObjid, "participant2act_entry" bs.RelateRecordsToID recP, "user", previousOwnerObjid, "participant2user" bs.Save End If End Sub Sub YANK_BTN_Click() Dim previousOwnerObjid As Long previousOwnerObjid = GetCurrentOwnerObjid() Me.DoDefault SaveParticipant previousOwnerObjid End Sub
Normally, I would add the participant record within Form_Save1 or Form_Save2, but this didn’t work. It exhibited some really strange behavior and threw some gawd-awful OST subsystem errors. So, I punted, and just added it after the default behavior happened on the Yank button.
Also notice that I only added support for cases and subcases. If you want to support other object types, add them to the Select Case portion of the GetCurrentOwnerObjid function.
Lets give it a whirl
From the Clarify Classic Client, Yank a case:
and then we should see an email notification come through:
and we should see the Yank activity and the Business Rule action in the case activity log:
You may now continue yanking away (does that sound slightly naughty?). And the person you yanked from will be notified appropriately.
Hope you find this useful.
And that wraps up my blog posting for 2011. See you in 2012.Rock on.