Search code examples
propertieswixcustom-action

Wix Custom Action Property Not Immediately Available


I have a Wix VBScript Custom Action that sets a Property, and then a publish event that is supposed to trigger based on the value of the set property. The issue seems to be that the property is not being set and in turn not triggering the next publish event. Has anyone successfully done something similar?

<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi"
     xmlns:hsi="http://schemas.hyland.com/wix/UtilityExtension">

  <Fragment>    
    <Property Id="FOO" Value="0" Secure="yes" />

    <CustomAction Id="Test3" Script="vbscript">
      <![CDATA[
      MsgBox Session.Property("FOO")
      ]]>
    </CustomAction>

    <CustomAction Id="Test2" Script="vbscript">
      <![CDATA[
      MsgBox "Test"

      ]]>
    </CustomAction>

    <CustomAction Id="Test1" Script="vbscript">
      <![CDATA[
      Session.Property("FOO") = "1"
      ]]>
    </CustomAction>
  </Fragment>
  <Fragment>
    <UI>
      <DialogRef Id="WarningModalDlg"/>

      <Dialog Id="BaseLawsonWebServerDlg" Width="370" Height="270" Title="Lawson LOB Broker Relay Setup">
        <Control Id="label" Type="Text" X="20" Y="50" Width="200" Height="16" Text="Test" TabSkip="yes" Transparent="yes" />

        <Control Id="Next" Type="PushButton" X="236" Y="243" Width="56" Height="17" Default="yes" Text="!(loc.WixUINext)">
          <Publish Order="1" Event="DoAction" Value="Test3">1</Publish>
          <Publish Order="2" Event="DoAction" Value="Test2">FOO = "1"</Publish>
          <Publish Order="3" Event="DoAction" Value="Test1">1</Publish>

        </Control>

        <Control Id="Back" Type="PushButton" X="180" Y="243" Width="56" Height="17" Text="!(loc.WixUIBack)"/>
        <Control Id="Cancel" Type="PushButton" X="304" Y="243" Width="56" Height="17" Cancel="yes" Text="!(loc.WixUICancel)">
          <Publish Event="SpawnDialog" Value="CancelDlg">1</Publish>
        </Control>

      </Dialog>
    </UI>
  </Fragment>
</Wix>

Event="DoAction" Value="Test1" fires, I've tested it. Event="DoAction" Value="Test2">FOO = "1" does not hit. Then Event="DoAction" Value="Test3">1</Publish> definitely hits and shows the message box with the default value.

Thanks ahead of time!


Solution

  • I figured it out! I was so used to the reverse order of UI Dialog Publish events that I did the same thing for Control publish events.

    Control Publish events move in the the order of 1 to x.

    The publish events should look like this instead:

     <Publish Order="1" Event="DoAction" Value="Test1">1</Publish>
     <Publish Order="2" Event="DoAction" Value="Test2">FOO = "1"</Publish>
     <Publish Order="3" Event="DoAction" Value="Test3">1</Publish>