Multiple Selection Listbox - Get Index number? - InfoPath Dev
in

InfoPath Dev

Multiple Selection Listbox - Get Index number?

Last post 05-12-2016 03:27 PM by Hilary Stoupa. 24 replies.
Page 1 of 2 (25 items) 1 2 Next >
Sort Posts: Previous Next
  • 06-22-2015 01:59 PM

    Multiple Selection Listbox - Get Index number?

    Hi everyone!

     Been following the site for a while and decided to join in, i'm a SP newbie but I can pick up things quickly. I might need some info/guidance if this is even possible at all.

     I have a form, within a form is a MSLB which is linked to another List outside the current library. I have implemented the double eval formula and set it into a textbox as a string, question is, is there anyway I can get the selected items from the MLSB into a format like this?

     Current Item selected is

    Item1; Item2; Item3

     Desired format:

    <1>Item1</1><2>Item2</2><3>Item</3>

     Desired format is to keep the formatting of the dataw within the form uniform as there's a bunch of fields that are repeated and I'm using the <number> Item </number> into 1 big string format.

    Any ideas or inputs about this? Thank you all

    "Be humble for you are made of Earth. Be noble for you are made of stars" - Serbian Proverb
  • 06-22-2015 03:53 PM In reply to

    Re: Multiple Selection Listbox - Get Index number?

     Hi - I'm rather confused about why you'd want to do this - but no matter, sample attached. Save the file locally, right click the saved file and select Design to open in design mode and preview. I did set "field1" to not be included by default under the Data > Default Values option. But the initial group selection could also be filtered out in the eval formula to exclude blanks.

    Hilary Stoupa

  • 06-23-2015 01:50 PM In reply to

    Re: Multiple Selection Listbox - Get Index number?

    Hi Hilary,

     Thank you so much for the quick response, I couldn't believe that that was even possible. I saw the formula you have from the sample and somehow I can't get it to work with mine. Is the location of the Group/MSLB a factor? Attached is a screenshot with the fields as well.

    https://goo.gl/photos/zMkZRAS74XGBJwR5A

    Thanks

    Nino

    "Be humble for you are made of Earth. Be noble for you are made of stars" - Serbian Proverb
    Filed under:
  • 06-23-2015 02:07 PM In reply to

    Re: Multiple Selection Listbox - Get Index number?

     Is the formula you are trying returning an error?

    I'd think you need count(preceding-sibling::my:mlstSubCategory .... etc for the count portion. And I'd add a filter on mlstSubCategory where you selected it (inside the second eval formula using the field picker) to include cannot be blank... 

    Hilary Stoupa

  • 06-23-2015 02:12 PM In reply to

    Re: Multiple Selection Listbox - Get Index number?

    Hi Hilary,

     No it doesn't return an error. It's just the count is not incrementing (always returns <1> </1>), same issue I have for another Repeating Table. I have another field that tracks the repeating number and it's set as

     Count(preceding-sibling::*/<Count Variable>)+1

    It worked on 2 other variables in the same form, for some reason it doesn't work for the 3rd count.

     Much appreciated with the insights and help! Thanks

    Nino

    "Be humble for you are made of Earth. Be noble for you are made of stars" - Serbian Proverb
    Filed under:
  • 06-23-2015 02:20 PM In reply to

    Re: Multiple Selection Listbox - Get Index number?

     You can attach your form to a reply under the options tab if you'd like me to take a look. :)

    Hilary Stoupa

  • 06-23-2015 02:24 PM In reply to

    Re: Multiple Selection Listbox - Get Index number?

    Here you go, advanced apologies for the newbie work here :D

    "Be humble for you are made of Earth. Be noble for you are made of stars" - Serbian Proverb
    Filed under:
  • 06-23-2015 02:42 PM In reply to

    Re: Multiple Selection Listbox - Get Index number?

     Did you try changing the count piece of the formula to my suggestion?

     count(preceding-sibling::my:mlstSubCategory) 

    I changed your  formula to:

    xdMath:Eval(xdMath:Eval(my:TDEInfo/my:SubCategories/my:mlstSubCategory[. != ""], 'concat("<", count(preceding-sibling::my:mlstSubCategory) + 1, ">", ., "</", count(preceding-sibling::*/mlstSubCategory[. != ""]) + 1, ">")'), "..")

    And put on another control bound to the repeating mlstSubCategory field (to work around not having access to your data sources) and it worked the same as in my test form. 

    Hilary Stoupa

  • 06-23-2015 02:53 PM In reply to

    Re: Multiple Selection Listbox - Get Index number?

    I did, I played around the formula because it was giving me errors :(
    "Be humble for you are made of Earth. Be noble for you are made of stars" - Serbian Proverb
  • 06-23-2015 03:03 PM In reply to

    Re: Multiple Selection Listbox - Get Index number?

     Try this one. Download the file. Right click the downloaded file and select Design to open in design mode.

    Hilary Stoupa

  • 06-23-2015 03:19 PM In reply to

    Re: Multiple Selection Listbox - Get Index number?

    Hi Hilary,

    That worked! Thanks a lot! I kind of have a basic understanding how the reference works now, thanks to you! :) Thank you so much Hilary!

    "Be humble for you are made of Earth. Be noble for you are made of stars" - Serbian Proverb
    Filed under:
  • 06-24-2015 07:54 AM In reply to

    Re: Multiple Selection Listbox - Get Index number?

    Hi Hilary,

     Ran into a weird scenario:

     I have a repeating table, I keep track of the number of items through an integer where it has the formula: count(preceding-sibling::*) + 1, this formula works for keeping track of the number of items. BUT it starts on 4. Any ideas why it's starting at 4? On other instance counter I have, count(preceding-sibling::*/<counter variable>) + 1 works.

    ** To remedy the above, i just added a -3 to my counters when being used to add tags to the repeating items, i know it's not a good remedy but just want to get an idea what's causing the 4 default number.

    "Be humble for you are made of Earth. Be noble for you are made of stars" - Serbian Proverb
    Filed under:
  • 06-24-2015 11:54 AM In reply to

    Re: Multiple Selection Listbox - Get Index number?

    I think that you may be counting the number of preceding sibling nodes inside the repeating group? I'm not sure.

    Is the field with the default formula inside the repeating group? You may want to use something like count(../preceding-sibling::my:RepeatingGroup) with "my:RepeatingGroup" replaced with your actual repeating group XPath. 

    Hilary Stoupa

  • 06-24-2015 12:08 PM In reply to

    Re: Multiple Selection Listbox - Get Index number?

    Worked like a charm! This gave me more understanding with the referencing part, I kind of had an idea that the grouping and variable location is a factor just not sure how to use the correct syntax for it. Thank you so much AGAIN Hilary :D
    "Be humble for you are made of Earth. Be noble for you are made of stars" - Serbian Proverb
    Filed under:
  • 05-11-2016 04:41 PM In reply to

    Re: Multiple Selection Listbox - Get Index number?

    Hi Hilary, I am wondering if you can help me. I've seen you giving great answers to a number of people on here. I'm using InfoPath 2010 and posting to a SharePoint list. I've tried following this thread, but am not able to get the formulas to work. Also, I don't need the HTML formatting that Nino needed. What I want is the selected Field Offices from a multiple-selection list box, to be concatenated together with index numbers between them, so that I can easily pull them out into separate fields, so that I can do something with them in a SharePoint Designer workflow later on. Basically I want something like this: Colorado Field Office1Kansas Field Office2Nebraska Field Office3 I am able to successfully run a double eval on my Field Office values and put commas between the values using: eval(eval(Value, 'concat(., ", ")'), "..") I am also able to successfully count the number of field offices selected using: count(Value[. != ""]) But when I try to put these together in the way that seems to make sense: eval(eval(Value, 'concat(., count(Value[. != ""]))'), "..") I get a message that I have errors in my formula. I've tried this many ways, and can't get it to work. eval(eval(Value, 'concat(., "count(Value[. != ""])")'), "..") eval(eval(Value, 'concat(Value, count(Value[. != ""]))'), "..") and everything else I can think of. Any thoughts? Many thanks for any help. Lara
Page 1 of 2 (25 items) 1 2 Next >
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.