Add items to dropdown list through VBscript. - InfoPath Dev
in

InfoPath Dev

Use our Google Custom Search for best site search results.

Add items to dropdown list through VBscript.

Last post 09-24-2010 11:52 AM by Potemkine. 13 replies.
Page 1 of 1 (14 items)
Sort Posts: Previous Next
  • 09-24-2010 08:59 AM

    Add items to dropdown list through VBscript.

    I am trying to populate a dropdown in infopath form, based on xml returned by a sharepoint webservice. (I know what u are thinking, why code? I need to perform some business logic before populating it) 

    The problem i am facing is that I do not know how to add the items to the drop-down.

     I found this,  http://social.msdn.microsoft.com/Forums/en-US/sharepointinfopath/thread/c9593115-24c1-4c3c-960e-3149916f3fdb

    It does exactly what I need, however its not in VB script, and I am not familiar  with converting it over to vb script.

     

     

    Is there a method or way to clone an item of an item from the dropdown and append to it in VBS.

    copyitem = DOM.SelectSingleNode("//my:myFields/my:fldChoices").clone()

    copyitem.displayname = "";

    copyitem.value = "";

    dropdown.append(copyitem)

     

     

    thanks in advance

  • 09-24-2010 10:07 AM In reply to

    Re: Add items to dropdown list through VBscript.

    hi, when you say

    vamirineni87:
    based on xml returned by a sharepoint webservice
    you mean you use the Infopath Wizard or you use code to query your list?

  • 09-24-2010 10:18 AM In reply to

    Re: Add items to dropdown list through VBscript.

    I used code to query for the data. Its not a list. Its user information from GetAllUserCollectionFromWeb.

    It returns an xml file that I want to parse and load usernames into a dropdown. 

    I figured out how to parse it and get the list of usernames and the IDs. but having problem populating the dropdown using the usernames as display names and IDs as values.

     

    I guess may be a "append" method of some sort?

     

     

     


  • 09-24-2010 10:25 AM In reply to

    Re: Add items to dropdown list through VBscript.

    Ok, I suggest you to use a reference field of your node and clone it, after that you append it to real node. To do that create a new group like "reference", right click on your repeating node, select reference...

     

  • 09-24-2010 10:40 AM In reply to

    Re: Add items to dropdown list through VBscript.

    Here some example of VBS :

    Dim oItem

    Set oItem = XDocument.DOM.selectSingleNode("XPATH").cloneNode(true)

    oItem.selectSingleNode("XPATHNameChild").text = "name"

    oItem.selectSingleNode("XPATHIDChild").text = "ID"

    XDocument.DOM.selectSingleNode("XPATHParent") .appendChild(oItem)

  • 09-24-2010 10:44 AM In reply to

    Re: Add items to dropdown list through VBscript.

     I have tried something very similar before. However this is the error I get when I try to preview the Infopath (2003) form.

    Expected end of statement
    File:script.vbs
    Line:279
        Set oItem = XDocument.DOM.selectSingleNode("//my:myFields/my:fldChoices").cloneNode(true);

     

     any ideas as to why this is occuring?

  • 09-24-2010 10:48 AM In reply to

    Re: Add items to dropdown list through VBscript.

    Can you please attach your form template ? when you reply click on option....

  • 09-24-2010 10:52 AM In reply to

    Re: Add items to dropdown list through VBscript.

     Here you go. The field name is 'fldChoices'

    and there is a button that tries to populate the dropdown.

     

     

  • 09-24-2010 11:11 AM In reply to

    Re: Add items to dropdown list through VBscript.

    Ok, tell me if it's ok for you.

  • 09-24-2010 11:12 AM In reply to

    Re: Add items to dropdown list through VBscript.

    EDIT: I only have office 2003. So I cannot open the form you have attached.

    ----------------------------------------------------------------------------------------------------------

    The error is minor.
    The ; semicolon at the end is screwing things up for some reason.


    For this statement
     oItem.selectSingleNode("XPATHNameChild").text = "name"
    XPATHNameChild doesnt make sence to me.


    if my fields are setup like this, "//my:myFields/my:fldChoices", there are no XPATHNameChild and XPATHIDChild.
    So do  I have to create other fields and somehow reference them to the dropdown?


  • 09-24-2010 11:33 AM In reply to

    Re: Add items to dropdown list through VBscript.

    Arf, ok check my image, I add 2 group and I bind my drop down to this group.


  • 09-24-2010 11:42 AM In reply to

    Re: Add items to dropdown list through VBscript.

    Here I save it to 2003 xsn...

  • 09-24-2010 11:51 AM In reply to

    Re: Add items to dropdown list through VBscript.

    You are the man!!!

    I never used binding before so, it was kinda confusing when I read binding.

    I really appreciate the help.

  • 09-24-2010 11:52 AM In reply to

    Re: Add items to dropdown list through VBscript.

    I'm glad that I could help you

     

Page 1 of 1 (14 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.