1

I've got a custom action that I want to pass in a sql server name and it populates the dropdown list with the results, however the dropdownlist does not get updates with the results

Added a custom action

[CustomAction]
        public static ActionResult PopulateAvailableDatabases(Session session)
        {
            const string availableDatabases = "AVAILABLE_DATABASES";

            session.Log("inside PopulateAvailableDatabases");

            var view = session.Database.OpenView($"DELETE FROM ComboBox WHERE ComboBox.Property='{availableDatabases}'");
            view.Execute();

            view = session.Database.OpenView($"SELECT * FROM ComboBox WHERE ComboBox.Property='{availableDatabases}'");
            view.Execute();

            var databases = GetDatabases(session);
            int index = 0;

            try
            {
                foreach (var database in databases)
                {
                    session.Log(database);

                    var record = session.Database.CreateRecord(3);
                    record.SetString(1, availableDatabases);
                    record.SetInteger(2, index++);
                    record.SetString(3, database);

                    view.Modify(ViewModifyMode.InsertTemporary, record);
                }
            }
            catch (Exception ex)
            {
                ex.ToString();
                session.Log("Exception Details: " + ex.Message);
            }
            view.Close();

            session.Log("Closing view");
            view.Close();
            return ActionResult.Success;
        }

This is in my dialog:

  <Control Id="FindDatabase" Type="PushButton" X="270" Y="65" Width="56" Height="17" Text="&amp;Find Databases">
          <!--<Publish Event="NewDialog" Value="WelcomeDlg">1</Publish>-->
          <Publish Event="DoAction" Value="PopulateAvailableDatabases">1</Publish>
          <!--<Publish Event="EndDialog" Value="Return">1</Publish>-->
        </Control> 

Here is the drop down:

  <Control Id="DatabaseNameLabel" Type="Text" X="47" Y="181" Width="100" Height="15" TabSkip="no" Text="&amp;Database:" />
        <Control Id="DatabaseNameEdit" Type="ComboBox" X="45" Y="194" Width="220" Height="18" Property="AVAILABLE_DATABASES">
          <ComboBox Property="AVAILABLE_DATABASES">
            <ListItem Text="[AVAILABLE_DATABASES]" Value="[AVAILABLE_DATABASES]"  />
          </ComboBox>
          <Publish Property="DATABASE_NAME" Value="0">1</Publish>
        </Control>
John
  • 263
  • 1
  • 15
  • I think [**Advanced Installer**](https://stackoverflow.com/a/50229840/129130) has fixed the dialog update problems if you run via a **`setup.exe`** launcher (commercial tool). Not sure how they have done that. I think it only works if you launch via the setup.exe, and not with extracted MSIs. Not positive. Telling you in case you are short on time and can afford a license. – Stein Åsmul May 21 '19 at 19:50
  • [Documentation here](https://www.advancedinstaller.com/user-guide/tutorial-combobox-listbox.html). And the [downloadable sample](https://www.advancedinstaller.com/examples/combolist.zip) (found inline in the text from the first documentation link). – Stein Åsmul May 21 '19 at 21:32
  • Got this working? – Stein Åsmul May 29 '19 at 01:16
  • Yes, I implemented the call on the next button click, and displayed the drop down in the next dialog – John May 29 '19 at 08:08
  • Nice workaround. You can add that as your own answer if you'd like. – Stein Åsmul May 29 '19 at 08:44
  • Updated my answer to summarize this. – Stein Åsmul May 29 '19 at 08:52

1 Answers1

0

MSI Dialog Update Problem Workaround: To work around MSI's dialog update problem (lacking / malfunctioning dialog update events), you can jump between dialogs to force update the state for all controls on the dialog. See Stefan Kruger's workaround below, or use the next button's click event to show control on next dialog as John states above.


Had to add as answer, too long for comment. Hints only.

github.com: Have a look at these samples from github: github.com search.

Update Problems: As I recall there are issue with dialog update problems when you hook DoActions up to button events (go back to previous dialog and then next again to see if list contains items). Try the dialog initialization event? Is that the one you are using perhaps?

Stefan Kruger's Workaround: Oh, and there is this from Stefan Kruger: http://www.installsite.org/pages/en/msi/articles/MultiListBox/index.htm. As I recall he jumps between two dialogs to deal with the update problem. It has been a while since I looked at it. It is VBScript-based, but generic concept.

Got to run, check later. Have fun.

Stein Åsmul
  • 39,960
  • 25
  • 91
  • 164