Context Sensitive ADX Form

Add-in Express™ Support Service
That's what is more important than anything else

Only registered users are allowed to subscribe.
Context Sensitive ADX Form
Form content changing depending on Inspector/Explorer and Compose 
Alex Carter




Posts: 34
Joined: 2019-02-21
Hi All,
I have an ADXOlFormsCollection which uses a form that shows on both Explorer and Inspector. It only shows on InspectorMode Compose on the inspector section.

By default the form loads with a single control visible with others hidden, the others are shown when an inspector starts up. To achieve this I am using the ADXBeforeFormShow event to change the visibly of the fields if an inspector is found. This works very nicely.

I am also using the same form on the explorer for inline responses. To achieve visibility of different form items when hitting reply/forward etc, I have made use of ExplorerInlineResponseEx and ExplorerInlineResponseCloseEx to show and hide the elements correctly.

The problem I have is that when I start the application and go straight to a folder outside my inbox (subfolder of inbox, sent items, deleted items etc) and hit reply/forward/reply all the form fields are not shown even though my ShowFields() method is executed. However if I go back to the inbox and click reply, the fields are shown. If I then move to other folders and hit reply, the fields are also shown correctly.

Am I having some sort of instance issue here? Would appreciate any help!

Thanks,
Alex
Posted 22 Aug, 2019 05:18:39 Top
Andrei Smolin


Add-in Express team


Posts: 16607
Joined: 2006-05-11
Hello Alex,

I don't think so. Can I look in the code handling the ADXBeforeFormShow event? If you wish, you can send it to the support email address; see {Add-in Express installation folder}\readme.txt. Please make sure your email contains a link to this topic.

Regards from Belarus (GMT+3),

Andrei Smolin
Add-in Express Team Leader
Posted 22 Aug, 2019 08:01:25 Top
Alex Carter




Posts: 34
Joined: 2019-02-21
I don't mind posting in here if that's OK with you?

This is from the form:

    Public Sub HideFields()
        lblEfileTitle.Visible = False
        lblAttention.Visible = False
        lblSection.Visible = False
        lblInbox.Visible = False
        lblNotes.Visible = False
        lblAttentionDate.Visible = False
        GrpTitleHint.Visible = False
        RadTitleClient.Visible = False
        RadTitleFA.Visible = False
        RadTitle3rdParty.Visible = False
        txtEfileTitle.Visible = False
        cmbAttention.Visible = False
        cmbSection.Visible = False
        cmbInbox.Visible = False
        txtNotes.Visible = False
        txtAttentionDate.Visible = False
        chkEfileComplete.Visible = False
        chkOcis.Visible = False
        chkDoNotFile.Visible = False

        Height = 24
    End Sub

    Public Sub ShowFields()
        lblEfileTitle.Visible = True
        lblAttention.Visible = True
        lblSection.Visible = True
        lblInbox.Visible = True
        lblNotes.Visible = True
        lblAttentionDate.Visible = True
        GrpTitleHint.Visible = True
        RadTitleClient.Visible = True
        RadTitleFA.Visible = True
        RadTitle3rdParty.Visible = True
        txtEfileTitle.Visible = True
        cmbAttention.Visible = True
        cmbSection.Visible = True
        cmbInbox.Visible = True
        txtNotes.Visible = True
        txtAttentionDate.Visible = True
        chkEfileComplete.Visible = True
        chkOcis.Visible = True
        chkDoNotFile.Visible = True

        Height = 95
    End Sub

    Private Sub eFilesAction_ADXBeforeFormShow() Handles Me.ADXBeforeFormShow
        Dim inspector As Outlook.Inspector = InspectorObj

        HideFields()

        If inspector IsNot Nothing Then
            Dim Item As Outlook.MailItem = inspector.CurrentItem
            If Item IsNot Nothing And Not Item.Sent Then
                ShowFields()
            End If
        End If
    End Sub


This is from the AddinModule to handle the changing of fields when inline response happens:


    Private Sub AdxOutlookAppEvents_ExplorerInlineResponseEx(sender As Object, itemObject As Object, sourceObject As Object) Handles AdxOutlookAppEvents.ExplorerInlineResponseEx
        Dim form As eFilesAction = AdxOlFormsCollectionItem1.GetCurrentForm()
        form.ShowFields()
    End Sub

    Private Sub AdxOutlookAppEvents_ExplorerInlineResponseCloseEx(sender As Object, sourceObject As Object) Handles AdxOutlookAppEvents.ExplorerInlineResponseCloseEx
        Dim form As eFilesAction = AdxOlFormsCollectionItem1.GetCurrentForm()
        form.HideFields()
    End Sub


Thanks,
Alex
Posted 22 Aug, 2019 08:22:33 Top
Alex Carter




Posts: 34
Joined: 2019-02-21
Morning Andrei,
If necessary I can supply the whole solution via the support email address if that is easier for you?

Regards,
Alex
Posted 23 Aug, 2019 04:53:38 Top
Andrei Smolin


Add-in Express team


Posts: 16607
Joined: 2006-05-11
Hello Alex,

No need to do this. I'm completing a test add-in project that provides necessary debug output. I suppose it will be ready in 10-40 minutes.

Regards from Belarus (GMT+3),

Andrei Smolin
Add-in Express Team Leader
Posted 23 Aug, 2019 05:00:13 Top
Alex Carter




Posts: 34
Joined: 2019-02-21
Hi Andrei,
Sounds good, I'll leave you to it then. Let me know how you get on.

Regards,
Alex
Posted 23 Aug, 2019 05:12:28 Top
Andrei Smolin


Add-in Express team


Posts: 16607
Joined: 2006-05-11
Alex,

Please check this project:

http://temp.add-in-express.com/support/MyAddin120-ForAlexCarter.zip

Regards from Belarus (GMT+3),

Andrei Smolin
Add-in Express Team Leader
Posted 23 Aug, 2019 05:23:30 Top
Alex Carter




Posts: 34
Joined: 2019-02-21
OK so I can see that the debug info is getting added to the Listbox as expected. Let me adjust my code to match your form detection in the AddinModule and see how it acts in comparison.
Posted 23 Aug, 2019 05:46:27 Top
Alex Carter




Posts: 34
Joined: 2019-02-21
Right so I have altered the AddinModule InlineResponse and Form BeforeShow events to be as follows:


    Private Sub eFilesAction_ADXBeforeFormShow() Handles Me.ADXBeforeFormShow
        Dim inspector As Outlook.Inspector = CType(Me.InspectorObj, Outlook.Inspector)
        HideFields()
        If inspector IsNot Nothing Then
            Dim Item As Object = inspector.CurrentItem
            If TypeOf Item Is Outlook.MailItem Then
                Dim mail As Outlook.MailItem = CType(Item, Outlook.MailItem)
                If Not mail.Sent Then ShowFields()
            End If
        End If
    End Sub



    Private Sub AdxOutlookAppEvents_ExplorerInlineResponseEx(sender As Object, itemObject As Object, sourceObject As Object) Handles AdxOutlookAppEvents.ExplorerInlineResponseEx
        Dim form As eFilesAction = CType(Me.AdxOlFormsCollectionItem1.GetForm(sourceObject), eFilesAction)
        If form IsNot Nothing Then
            form.ShowFields()
        End If
    End Sub

    Private Sub AdxOutlookAppEvents_ExplorerInlineResponseCloseEx(sender As Object, sourceObject As Object) Handles AdxOutlookAppEvents.ExplorerInlineResponseCloseEx
        Dim form As eFilesAction = CType(Me.AdxOlFormsCollectionItem1.GetForm(sourceObject), eFilesAction)
        If form IsNot Nothing Then
            form.HideFields()
        End If
    End Sub


This seems to fix the issue where the fields were not shown on emails outside of the inbox on initial load of Outlook.

It looks like the issue is related to using the GetCurrentForm() method in the InlineResponseEx event. After changing to use GetForm and passing the sourceObject to identify the instance, the fields are shown correctly. Is there a reason for this?

Thanks for the help!
Posted 23 Aug, 2019 06:00:14 Top
Andrei Smolin


Add-in Express team


Posts: 16607
Joined: 2006-05-11
Hello Alex,

Alex Carter writes:
Is there a reason for this?


I don't have an answer. We will investigate this.

I've found a mistake in my code: it leaves unreleased the COM object created by calling inspector.CurrentItem. Sorry for this.

Here's a corrected version; I've also updated the ZIP file above.

    Private Sub eFilesAction_ADXBeforeFormShow() Handles Me.ADXBeforeFormShow
        Dim inspector As Outlook.Inspector = CType(Me.InspectorObj, Outlook.Inspector)
        HideFields()
        If inspector IsNot Nothing Then
            Dim Item As Object = inspector.CurrentItem
            If TypeOf Item Is Outlook.MailItem Then
                Dim mail As Outlook.MailItem = CType(Item, Outlook.MailItem)
                If Not mail.Sent Then ShowFields()
            End If
            If Item IsNot Nothing Then Marshal.ReleaseComObject(Item) : Item = Nothing
        End If
    End Sub


Regards from Belarus (GMT+3),

Andrei Smolin
Add-in Express Team Leader
Posted 23 Aug, 2019 06:53:50 Top