• Creator
    Topic
  • #4120
    CLKurutz
    Participant

      Hello. I have created custom views with the GW View Designer. I have a field named “Table Linens”. I would like to use a Formativ forms designed custom form to gather information. For example, the table linen requirements. I would then like to insert that information into my custom view from the view designer.

      I have it working for standard fields. Is there a way to reference custom fields?

      This is my code that works for standard fields:

      Set objMessage = GroupWise.ComposingItem
      objMessage.Subject = ActivityRoom.mSetup.Text
      ‘this is a custom form I created to gather the information needed for the main view.

      I tried:
      objMessage.TableLinens = “testing”

      Nothing is being inserted in my custom fields.

      Any help would be appreciated.

    • Author
      Replies
    • #7167
      Support 1
      Participant

        As I understand your enquiry, you are looking at how to add custom fields to a GroupWise message. In the GroupWise Object API, the Message object has a property Fields which is a collection of Field (ie. ‘custom field’) objects. Fields is not available via GroupWise.ComposingMessage; as a result you will need to use either an existing message, or else create a new message entirely in code.

        Here is a simple example:

          const CUSTOM_FIELD_ID = "Acme Electrical Hardware"
        
          ...
        
          dim oFieldDef, oFieldDefs, oMsg
        
          ' Initialize oMsg to something we can compare.
          set oMsg = nothing
        
          ' Get a reference to the open (not composing) message view.
          set oMsg = Client.ClientState.CommandMessage
        
          ' (Alternatively, create a new message.)
          ' set oMsg = GroupWise.Account.MailBox.Messages.Add("GW.MESSAGE.MAIL", fgwDraft)
          ' Initialize other fields...
        
          ' Add a custom field.
          if not (oMsg is nothing) then
            set oFieldDefs = GroupWise.Account.FieldDefinitions
        
            ' Is our custom field defined?
            set oFieldDef = nothing
            set oFieldDef = oFieldDefs.Item(CUSTOM_FIELD_ID, fgwString)
            if oFieldDef is nothing then
              ' No - add a definition now.
              call oFieldDefs.Item(CUSTOM_FIELD_ID, fgwString)
            end if
        
            call oMsg.Fields.Add(CUSTOM_FIELD_ID, fgwString, _
              "Acme Electrical goods are the best!")
          end if
        

        For more details, see the online documentation for Fields.

        I hope this helps you.

        Advansys Support

        #7165
        CLKurutz
        Participant

          Hello. Thank you for the suggestions. I am not sure if I was clear in my original message. I have already created “user-defined” fields with the GW view designer. I took the standard appointment view and added some fields. I have tried to use the code posted but I couldn’t get it to work.

          What I have is a pop up dialog box (built with Formativ). In this dialog box, I capture information on Table Linens. I would like to take that information and insert it into my custom GW Appointment in a specific field. The field being my user-defined field “TableLinens”. If I try to insert it into a “standard” field (i.e., subject), it works fine. I just don’t know how to get it to recogize the user-defined fields.

          Thanks again for your thoughts.

          #7162
          Support 1
          Participant

            You can use the Object API as follows to add some captured information to an existing appointment message.

            ' This assumes the custom field "TableLinens" has been defined for the GroupWise account.
            
            const CUSTOM_FIELD_ID = "TableLinens"
            
              .
              .
              .
            
            ' AddLinensInfo adds the captured information (a string) in aInfo to the open
            ' message as the custom field represented by the constant CUSTOM_FIELD_ID.
            sub AddLinensInfo(aInfo)
            
              dim oMsg
            
              set oMsg = nothing
              set oMsg = Client.ClientState.CommandMessage
              if not (oMsg is nothing) then
                call oMsg.Fields.Add(CUSTOM_FIELD_ID, fgwString, aInfo)
              end if
            
            end sub
            

            I hope this helps you.

            Regards,
            Advansys Support

            #7164
            CLKurutz
            Participant

              Thank you for the additional information. I unfortunately still can not get it to work. What did you mean by:

              This assumes the custom field “TableLinens” has been defined for the GroupWise account.

              My code will run but the information I type in the custom form is not inserted into the custom appointment view. It is like it can not find the user-defined field “TableLinens”.

              Thanks again.

              #7161
              Support 1
              Participant

                quote:


                What did you mean by:

                This assumes the custom field “TableLinens” has been defined for the GroupWise account.


                I gather from your earlier message that the above is implied by ‘I have already created “user-defined” fields with the GW view designer.’

                Regarding the GroupWise Object API, custom fields can be defined at least at the levels of Account object and Folder object, viz.

                GroupWise.Account.FieldDefinitions

                In order to retrieve a specific custom field value in a message, you can use the Object API in the following way:

                const CUSTOM_FIELD_ID = "TableLinens"
                
                  .
                  .
                  .
                
                  dim iText
                  dim oField
                  dim oMsg
                
                  set oMsg = nothing
                  set oMsg = Client.ClientState.CommandMessage
                  if not (oMsg is nothing) then
                    set oField = oMsg.Fields.Item(CUSTOM_FIELD_ID, fgwString)
                    if oField is nothing then
                      iText = "Field " & CUSTOM_FIELD_ID & " not found"
                    else
                      iText = "Field value: " & oField.Value
                    end if
                
                    MsgBox iText
                  end if
                

                Can you confirm that the ‘user-defined’ fields you created with the GW view designer are equivalent to the custom fields in the Object API?

                I hope this information is helpful.

                Regards,
                Advansys Support

                #7169
                CLKurutz
                Participant

                  Thank you again for your response. I received this error message when running your code:

                  Fields.Object
                  C:Documents and SettingsAdministratorMy DocumentsAdvansysFormativAppletsRoom Setup Activity Old.vbf
                  Fields collection is empty at line 25, column 5

                  Any help would be appreciated.

                  #7168
                  Support 1
                  Participant

                    It sounds like the “user-defined” fields you added to the standard appointment view apply only at the user interface. That is, the GW view designer does not automatically define corresponding custom fields in the GroupWise Account or folders. (Note that I don’t have personal experience with this designer – I am guessing on this point.)

                    Assuming this is correct, then you will need to define “TableLinens” manually as a custom field, as per the example in my first response above. Then, to retrieve the “TableLinens” value from an existing appointment, use the approach suggested in my last response.

                    NB: It is not possible to add custom fields to a composing message that has not been saved into the GroupWise message store. The only way to add custom fields is via the Object API-based techniques.

                    As a result, I think you will not be able to use your custom appointment view to enter custom fields while composing a new appointment, though you might be able to use it to view/edit existing appointments.

                    You may like to email your applet to support@advansyscorp.com. We will take a look at the applet and if possible advise you on how to make it work.

                    Regards,
                    Advansys Support

                    [This message was edited by Support 3 on April 10, 2005 at 04:33 PM.]

                    #7166
                    jeka
                    Participant

                      Hi,

                      How can I get with this Function a “check box type”

                      Regards

                      Jens Kasper

                      #7163
                      Support 1
                      Participant

                        If you wish to define a Boolean-valued custom field, then you could replace the constant fgwString by fgwNumeric in the above code examples. However, since every variable in VBScript is a Variant, you could assign a Boolean value to a string-typed field, and the value will be stored as a valid string representation.

                        In some cases you may need to use explicit type coercion when writing and reading a Boolean value (but this is not usually necessary), as in the following:

                          oCheckBox.Checked = CBool(oField.Value)

                        You can review the range of available constants in the Formativ Language Guide. To see these, go to the Contents tab and select Reference | Constants | eFieldType.

                        I hope this information helps you.

                        Regards,
                        Advansys Support

                      Viewing 9 replies - 1 through 9 (of 9 total)
                      • You must be logged in to reply to this topic.