/ Forums / Advansys Formativ / Creating Solutions with Formativ / Custom Fields
-
CreatorTopic
-
May 12, 2009 at 6:27 am #4412
Hi,
Is there a way to insert text into a custom field of a ComposingItem?
I can insert once a real message is created. But when in composing item the .Fields property is not supported.
I am trying to add some text to an outgoing email (ComposingItem), this information cannot be an attachment. I was trying the Custom Fields and will investigate x-fiedls…
Is there a way to do this with an x-field?
Any work-arounds appreciated.Thanks
-
CreatorTopic
-
AuthorReplies
-
May 12, 2009 at 5:13 pm #8120
Unfortunately, you can not add custom fields to a composing/draft message. However, you can add when the message is saved (i.e. stored in GroupWise database). You can save draft message using ItemSaveMessageDraft() token to save a draft copy of the current message in the specified folder. If no folder is specified, the user is prompted to indicate which folder to use.
See the following thread for more information: http://www.advansyscorp.com/forums/topic/2131098961/
We haven’t investigate X-Field on composing message, please let us know if you have any success.
Regards,
Advansys SupportMay 26, 2009 at 1:35 pm #8121I created my own class to handle adding custom fields to a draft message using the Novell Object API. I hope the following code is of some assistance to you.
quote:
‘ Custom Fields
Set myFields = New CCustomFields
If myFields.AttachToMsg(DraftMsg) Then
Call myFields.SetFieldValue(FIELD_ACCOUNT, NewMsgDlg.eAccount.Text, fgwString)
Call myFields.SetFieldValue(FIELD_PROJDESC, NewMsgDlg.eProjectDesc.Text, fgwString)
End If
Here is the full code of how I send a message with custom fields:
'------------------------------------------------------------------------------- ' Send the message '------------------------------------------------------------------------------- Function SendMessage(ByVal RecipientEmail, ByVal CCEmail, ByVal BCEmail, ByVal Subject, ByVal BodyText, ByVal AttachList) Dim i, DraftMsg, SentMsg, myFields SendMessage = "" ' Use the Object API to create a new draft email message Set DraftMsg = GroupWise.Account.Mailbox.Messages.Add("GW.MESSAGE.MAIL", fgwDraft) ' Subject and Body DraftMsg.Subject = Subject DraftMsg.BodyText.PlainText = BodyText ' Recepient Field If RecipientEmail.Count > 0 Then For i = 0 To RecipientEmail.Count - 1 Call DraftMsg.Recipients.Add(RecipientEmail.EmailAddress(i), "NGW", fgwTo) Next End If ' CC Field If CCEmail.Count > 0 Then For i = 0 To CCEmail.Count - 1 Call DraftMsg.Recipients.Add(CCEmail.EmailAddress(i), "NGW", fgwCC) Next End If ' BC Field If BCEmail.Count > 0 Then For i = 0 To BCEmail.Count - 1 Call DraftMsg.Recipients.Add(BCEmail.EmailAddress(i), "NGW", fgwBC) Next End If ' Attachments Dim sFilename For i = 0 to AttachList.Items.Count - 1 sFilename = Toolbox.NormalizeFilePathLoc(AttachList.Items(i).SubItems(0)) Utilities.Trace "Attach sFilename " & sFilename DraftMsg.Attachments.Add(sFilename) Next ' Custom Fields Set myFields = New CCustomFields If myFields.AttachToMsg(DraftMsg) Then Call myFields.SetFieldValue(FIELD_ACCOUNT, NewMsgDlg.eAccount.Text, fgwString) Call myFields.SetFieldValue(FIELD_PROJDESC, NewMsgDlg.eProjectDesc.Text, fgwString) End If ' Send the message and return the message ID Set SentMsg = DraftMsg.Send If not SentMsg is nothing then Utilities.Trace "SentMsg.MessageID=" & SentMsg.MessageID SendMessage = SentMsg.MessageID Set SentMsg = Nothing End If Set DraftMsg = Nothing Set myFields = Nothing End Function
And here is my class to handle custom fields:
'------------------------------------------------------------------------------- ' ' CCustomFields Class ' ' Methods: ' AttachToMsg(Msg) - Attach to the current message. Return a boolean indicating success ' SetFieldValue(TheName, TheValue, TheType) - Store TheValue in TheName field ' GetFieldValue(TheName, TheType) - Return the value currently stored in the custom field of TheName ' ' Use: ' Dim iFields ' Set iFields = New CCustomFields ' iFields.AttachToMsg(Msg) ' MsgBox (iFields.GetFieldValue(FIELD_NAME,1) ' Call iFields.SetFieldValue(FIELD_NAME,Value,1) ' ' TheType is of eFieldType ' fgwString 1 String ' fgwNumeric 2 Numeric (32 bits) ' fgwDate 3 Date ' fgwBinary 4 Binary ' fgwReserved 5 Reserved ' ' ' This class contains methods designed to make access to GroupWise message ' custom fields simpler. Use the AttachToMsg to connect to the message we ' want to write to/read from, then use the SetFieldValue()/GetFieldValue() ' methods to read/write the data ' '------------------------------------------------------------------------------- class CCustomFields Private iMsg Private Sub class_terminate set iMsg = nothing End sub Public Function AttachToMsg(ByRef Msg) If Toolbox.SkipErrors Then On Error Resume Next AttachToMsg = false set iMsg = Msg if iMsg is Nothing then exit function else AttachToMsg = true end if Toolbox.OnErrorCheckUp("AttachToMsg") end function Public Sub SetFieldValue(ByVal TheName, ByVal TheValue, ByVal TheType) If Toolbox.SkipErrors Then On Error Resume Next If Len(TheName) = 0 Then Exit Sub If Not FieldExists(TheName, TheType) Then Call GroupWise.Account.FieldDefinitions.Add(TheName, TheType) End If Call iMsg.Fields.Add(TheName, TheType, TheValue) Toolbox.OnErrorCheckUp("SetFieldValue") End Sub Public Function GetFieldValue(TheName, TheType) If Toolbox.SkipErrors Then On Error Resume Next Dim iField If iMsg.Fields.Count > 0 Then Set iField = iMsg.Fields.Item(TheName, TheType) GetFieldValue = iField.Value Else GetFieldValue = "" End If Toolbox.OnErrorCheckUp("GetFieldValue") End Function Private Function FieldExists(TheName, TheType) If Toolbox.SkipErrors Then On Error Resume Next Dim FieldObj Dim FieldDefs Set FieldDefs = GroupWise.Account.FieldDefinitions Set FieldObj = FieldDefs.Item(TheName,TheType) If IsObject(FieldObj) Then FieldExists = TRUE Else FieldExists = FALSE End If Toolbox.OnErrorCheckUp("FieldExists") Set FieldObj = Nothing Set FieldDefs = Nothing End function End Class ' ' End CCustomFields Class '-------------------------------------------------------------------------------
Please note: You cannot use this class as is, because there are other classes involved that I have not presented.
May 26, 2009 at 6:27 pm #8119Thanks “ctaleck” for sharing this code with us.
Regards,
Advansys Support -
AuthorReplies
- You must be logged in to reply to this topic.