Edit 4/30:
A couple of notes, now that I've had the weekend to go over this.
First, this technique was originally blogged by David Musgrave in 2008: http://blogs.msdn.com/b/developingfordynamicsgp/archive/2008/07/24/hybrid-dynamically-populating-a-modifier-added-list.aspx. Props to David. There are a lot of cool things that might be done using this approach. I'd realy love to hear anyone's thoughts.
If you don't follow David's blog... you should. He's the author of Menus for VS Tools and spoke (OK, evangelized) at Convergence 2012 on the Support Debugging Tools for Dynamics.
Second, after coding the example below I discovered that if you were to use this technique to put 'A' and 'C' into a dropdown list, the 'value' that list returns would be '1' and '2'. If the dataset changed in the future to 'A', 'B' and 'C', then 'C' would now return a value of 3. That would cause trouble with saving the 'value' in the database; so I'm recommending this technique only for items that remain static (like SOP Order Types)
Sub OpenAfterOriginal(ByVal sender As Object, ByVal e As System.EventArgs)
Try
Dim CompilerApp As Object
Dim CompilerMessage As String = ""
Dim CompilerError As Integer
Dim CompilerCommand As String = ""
CompilerApp = CreateObject("Dynamics.Application")
'get a dataset of items that we want to add to the dropdown list
Dim oDT As DataTable = RLData.SPs.Dyn_MC40301_SEL().getTable
For Each oRow As DataRow In oDT.Rows
'loop through the datatable
'format the SanScript commant
CompilerCommand = String.Format("add item ""{0}"" to '(L) Exchange' of window GL_Account_Maintenance of form GL_Account_Maintenance;", oRow("EXGTBLID"))
'MsgBox(CompilerCommand)
' Execute SanScript
CompilerApp.CurrentProductID = 0 'Dynamics
CompilerApp.CurrentProduct = CompilerApp.CurrentProduct & "!Modified"
CompilerError = CompilerApp.ExecuteSanscript(CompilerCommand, CompilerMessage)
If CompilerError <> 0 Then
Throw New Exception(CompilerMessage)
End If
Next
Catch ex As Exception
ErrorHandler.globalErrorHandler(ex, True)
End Try
End Sub