How to refresh a dialog after setting a property

ImportantThe following article uses options that are available starting with the Enterprise edition and project type.

This article explains how to refresh a dialog after modifying properties that were used on that dialog.

In order to initiate a refresh on an EXE UI Dialog, you only need to trigger the Refresh the current dialog published event after your property has been updated. Each time the Refresh the current dialog event is triggered, the user interface refreshes.

Below is a sample VBScript that retrieves the value of MYPROP property, increments it by one, then updates the property with the new value. Upon this modification, the dialog needs to be refreshed, so the Refresh the current dialog event should be triggered just after the VBScript execution.

Dim x

'Retrieve the value of MYPROP
x = Session.Property("MYPROP")

'Test if MYPROP is empty (i.e it does not already exist). If it is, initialize it
If x = "" Then
  x = 0
Else
  'Increment x
  x = x+1
End If

'Write the incremented value back into MYPROP
Session.Property("MYPROP") = cstr(x)
        

You can save the above script in a .vbs file and add it as a custom action without sequence in Custom Actions page. You can then call it by placing an Execute custom action published event on a button. After the Execute custom action published event you should add the Refresh the current dialog event.

Also, make sure you also have a static text with the "Property" field set to "MYPROP" and the "Text" field set to "[MYPROP]" on the same page with your button, so you can see the updated value.