Revenera Documentation site will be unavailable on July 2nd due to scheduled maintenance. For more information see the status dashboard.

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
proactis
Level 4

Populating Combobox with custom action

Hi I am trying to get a combo list to be able to be populated with values that are held in an xml file.

I have tried to get the script below to work but it just falls over, typically installshield giving me not a clue why.

If I run the script without trying to insert an item into the MSI Database so that a message box just appears it works without issue.




Dim objView
Dim objDB
Dim objInstaller
Dim objRecord
Dim SiteName, Bindings, objNode


Set MsiDb = Session.Database
Set MsiInstall = Session.Installer
Set MsiView = MsiDb.OpenView("SELECT * FROM ComboBox")


Set xmlDoc = CreateObject("Msxml2.DOMDocument")
xmlDoc.load("c:\test.xml")

Set ElemList = xmlDoc.getElementsByTagName("SITE")


index=0
i=1
SiteName = ElemList.item(index).getAttribute("SITE.NAME")
Bindings = ElemList.item(index).getAttribute("bindings")

For Each objNode in ElemList

Msgbox SiteName + Bindings

'Now Populate the ComboBox with the strRegionName and strRegionValue items
Set objRecord = objInstaller.CreateRecord(4)
objRecord.StringData(1) = "SITELIST" ' property name
objRecord.IntegerData(2) = i' order
objRecord.StringData(3) = SiteName' value
objRecord.StringData(4) = Bindings' text
' now add the record to the table
Call objView.Execute(objRecord)
Call objView.Modify(7, objRecord) ' (7 = msiViewModifyInsertTemporary)

index=index+1
i =i + 1
Next

Call MsiView.Close
Labels (1)
0 Kudos
6 Replies
hidenori
Level 17

The objView object never seems to be assigned. You may need to change your code as follows. It still does not work, see InstallShield Developer Tip: Accessing the MSI Database at Run Time.


Dim objView
Dim objDB
Dim objInstaller
Dim objRecord
Dim SiteName, Bindings, objNode


Set MsiDb = Session.Database
Set MsiInstall = Session.Installer
Set objView = MsiDb.OpenView("SELECT * FROM ComboBox")
objView.Execute


Set xmlDoc = CreateObject("Msxml2.DOMDocument")
xmlDoc.load("c:\test.xml")

Set ElemList = xmlDoc.getElementsByTagName("SITE")


index=0
i=1
SiteName = ElemList.item(index).getAttribute("SITE.NAME")
Bindings = ElemList.item(index).getAttribute("bindings")

For Each objNode in ElemList

Msgbox SiteName + Bindings

'Now Populate the ComboBox with the strRegionName and strRegionValue items
Set objRecord = objInstaller.CreateRecord(4)
objRecord.StringData(1) = "SITELIST" ' property name
objRecord.IntegerData(2) = i' order
objRecord.StringData(3) = SiteName' value
objRecord.StringData(4) = Bindings' text
' now add the record to the table
' Call objView.Execute(objRecord) <-- Comment out
Call objView.Modify(7, objRecord) ' (7 = msiViewModifyInsertTemporary)

index=index+1
i =i + 1
Next

Call objView.Close
0 Kudos
proactis
Level 4

I have tried the changed code and it still falls over.

Any other ideas?
0 Kudos
Holger_G
Level 10

Christopher Painter posted a nice DTF sample to dynamically generate UI content on his blog a while ago. Maybe that´s an option for you.
0 Kudos
hidenori
Level 17

Make sure that you are using an immediate execution custom action. You may not be able to use a deferred execution custom action for your script because it can only access to a very limited information of installation. For more information, see Obtaining Context Information for Deferred Execution Custom Actions.
0 Kudos
Server
Level 5

I also would strongly recommend switching to C# and DTF and don't bother with VB stuff anymore.
0 Kudos
proactis
Level 4

I have managed to solve the issue, I would switch to C but I don't know a thing about C and haven't got the time to learn


PS what is DTF?

Dim SiteName, Bindings

Const msiViewModifyInsertTemporary = 7
Const IDOK = 1

Set viewlist = Database.OpenView("SELECT * FROM `ComboBox` WHERE `Property`='REGION'")
viewlist.Execute

Set xmlDoc = CreateObject("Msxml2.DOMDocument")

if not xmlDoc.load("c:\test.xml") then
msgbox "Failed to load xml - " & xmlDoc.parseError.reason
end if

r = 0

for each objElement in xmlDoc.documentElement.selectNodes("SITE")

SiteName = objElement.getAttribute("SITE.NAME")
Bindings = objElement.getAttribute("bindings")

Set reclist = Installer.CreateRecord(4)

r = r + 1
reclist.StringData(1) = "REGION"
reclist.IntegerData(2) = r
reclist.StringData(3) = SiteName
reclist.StringData(4) = Bindings + SiteName

viewlist.Modify msiViewModifyInsertTemporary, reclist

Next
0 Kudos