Full code example for replace in form definitions
Sub CreateNewSatellite(Hub)
Dim dlg
Dim Sources
Dim FrmDef
Dim XML
Dim Model
Set Model = Hub.Parent
Set dlg = Hub.CreateCustomDialog("%CurrentTargetCode%.Satellite select Source")
If not dlg is Nothing Then
Sources = GetHubSources(Hub)
If Sources = "" Then
MsgBox "No sources defined for this Hub"
Else
Set FrmDef = dlg.FormDefinition
' Save the form definition so we can restore it later
XML = FrmDef.Value
' Replace the placeholders with actual values
FrmDef.Value = Replace(FrmDef.Value, "cmb_SelectSource.Values", Sources)
FrmDef.Value = Replace(FrmDef.Value, "cmb_SelectSource.Value", "")
If dlg.ShowDialog() then
' restore the form definition
FrmDef.Value = XML
MsgBox = dlg.GetValue("cmb_SelectSource")
Else
' restore the form definition also when cancel is clicked
FrmDef.Value = XML
End If
End if
End If
End Sub
Function GetHubSources(Hub)
Dim Sources
Dim Att
Dim MapItem
Dim SourceFeature
Sources = ""
For Each Att In Hub.Attributes
If Att.Mappings.Count > 0 Then
For Each MapItem In Att.Mappings
For Each SourceFeature In MapItem.SourceFeatures
If Instr(1,Sources,SourceFeature.parent.code & "\r\n") = 0 Then
Sources = Sources & SourceFeature.parent.code & "\r\n"
end if
Next 'SourceFeature
Next 'MapItem
End If ' Mapping count
Next
GetHubSources = Sources
End Function
Sub %Method%(obj)
If Left(obj.StereoType,3) = "Hub" Then
CreateNewSatellite obj
Else
MsgBox obj.Name & " is not a Hub"
End if
End Sub