Splitting delimited string - InfoPath Dev
in

InfoPath Dev

Splitting delimited string

Last post 04-20-2012 08:37 AM by Hilary Stoupa. 3 replies.
Page 1 of 1 (4 items)
Sort Posts: Previous Next
  • 04-19-2012 03:27 PM

    Splitting delimited string

    I've developed an equipment booking site based on the group work site template in Sharepoint 2010. This allows our content production teams to book out video cameras, microphones etc from the equipment store for use on location.

    I'm trying to extend the functionality to include checking items in and out of the store so that the equipment can be tracked more easily.

    The equipment selected is saved to a field in the bookings calendar list in a delimited format. For example - 21;#C Stand - 1;#38;#Avenger foam board holder'#37;#Apple iPad
    This booking would show as having C Stand - 1, Avenger foam board holder and Apple iPad as the reserved equipment.
    The numbers are the ID numbers, with ;# being the delimiter.

    The problem I'm facing is that when I go through the check out process, the items are displayed exactly as written above. This makes no sense to the users. I want to instead show just the names of the items.

    Therefore, I need to work out how to split the string.

    The challenges -
    - The string will vary in length depending on how many items are reserved
    - The names of each item will vary in length.
    - I am not a coder and would ideally like to achieve this with out of the box functionality.

    There are two possibilities
    - Parse it in a SharePoint workflow and store the list of names (or ID's) in a different field (the workflow string parsing functions are too restrictive for this)
    - Parse it when the infopath form is loaded and extract the names (or ID's) and build the field (Calculated Value) for display on the fly.

    I think I need to utilise substring functions in InfoPath however I can't get my head around how to make it work dynamically...

    Any help is greatly appreciated!
  • 04-19-2012 04:02 PM In reply to

    Re: Splitting delimited string

    So, I guess I'm a little confused as to where these values are coming from - you say:

    The equipment selected is saved to a field in the bookings calendar list in a delimited format

    This is equipment selected in an InfoPath form? In a drop down or something? Is a single item selected at a time, and then you promote the repeating field as merged? If that is the case, I'd probably take the easy route - add another field to my form's repeating data source, and when my user selects each piece of equipment, I'd run a rule to populate my new field with a formula - substring-after(., "#") - so my new field would just have Avenger foam board holder, for example. Then I'd promote this new field as merged instead of my original field.

    However, I may have completely misunderstood what you are doing.

    Hilary Stoupa

  • 04-19-2012 06:24 PM In reply to

    Re: Splitting delimited string

    Sorry I should have made that clear.

    It's not selected through an InfoPath form - it's using the out of box calendar booking form from the group work site in SharePoint. The items available to select in the form are populated from another list (named equipment) which contains the bookable items, and when the booking is saved to the calendar list, the list of items is aggregated as above. This all happens automatically, out of the box group work site functionality.

    InfoPath sees the data as I posted when it reads the list items. For example, the booking above would be as such:
    Name: Bill
    Start Date: 20/04/2012
    Start Time: 11:00am
    End Date: 20/04/2012
    End Time: 1:00pm
    Location: Beach
    Equipment: 21;#C Stand - 1;#38;#Avenger foam board holder'#37;#Apple iPad

    So, the equipment list is an aggregated reference to items in another list, that the user has selected.
    I cannot edit the Sharepoint form due to the fact that the list of equipment is an external content type. I'm stuck with that form and effectively trying to draw two independent functions together.
    The various views in SharePoint interpret this data correctly and display it in a comma separated fashion without the ID numbers. I want to be able to emulate this outside of SharePoint.

    So I guess, I effectively have an entire string being read from a field which I want to break up and change the format of - ideally just the names, comma separated.

    Hope that helps explain what I'm trying to achieve.
  • 04-20-2012 08:37 AM In reply to

    Re: Splitting delimited string

    Oh, yuck.

    There really isn't any replace function in IP - and this would most cleanly be done with Regex.Replace in code, I think (which, I realize this was not your intent, but you have just given me a VERY GOOD command to add to qRules 4.2!).

    I think you'd have to write code for this. If you can live with it till June and are interested in qRules, I am pretty sure the 4.2 release in June will have a way for you to replace using regular expressions... ;-)

    Hilary Stoupa

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