Multi Choice in Repeating Section Struggles

  • 18 October 2019
  • 4 replies
  • 4 views

Badge +2

All - I'm struggling with multi select checkbox within repeating section.  

I have a New part number request.  within the repeating section (a user can request multiple parts at the same time) - there is a selection for which warehouses the part applies to.  This is a multi select checkbox.

I am iterating the repeating section just fine, and I'm extracting the warehouse data to a collection.  no problem there.  

 

the issue is, the data that comes out as (index number, semi colon, warehouse number).  so let's say I select warehouse 21 and 92.   I get this as a result.   12;21#;32;92#; 

I need to run an additional expression to obtain just the 21 and just the 92 when processing through the results. 

 

right now, in my iteration of the row data, I extract the single row selections - which is the text above.  I then have an expression setup to split based on the #; syntax, but I then end up with a new collection of 12;21 and 32;92 which I would loop thru to send emails to line buyers based on which warehouse was selected.  I would add another expression but a split will assign 12 and 21 to another colelction, when I only need the right side of the semi colon.  I was thinking extract, but I don't know the syntax.  I would split with ; and only need the right side of the text. 

help!  thank you- 


4 replies

Badge +12

@TroyB ...it seems you have a lookup column. Use parselookup function and get the warehouse #

Badge +2
I'm not sure I follow. I named my repeating section and use the query xml function on the list column containing the xml. the control on the repeating section is a list lookup, so that if options change or in this case a warehouse added, it will add to the form dynamically. I extract the xml nodes into collection variables in the xml query function, then process from there in a loop. then because of the multiple choice - i have a loop within the row data loop to parse the warehouses. where do i need to go exactly to change the setting to get back only the value rather than the index and value? in the control settings, I have ID preamble set to no. but I'm still getting it.
Userlevel 5
Badge +14

Long story short, you're going to need to use two different Collections and two different For Each Loops

One Collection is going to store the Multi-Selection Lookup Control data from every Row of your Repeating Section. 

And the other Collection will be used to store the Individual Selections of your Lookup. 

 

The problem is that Lookup Controls will place their Index before the value, and in your case I believe that's messing you up. So we'll just need to use some additional Regular Expressions to better format the data so that you can split them in a way that retains the stuff you want (Value) while dropping the things you don't (ID) 

Example Time. 

Let's say we have a Row with a Multi-Selection Lookup Control with the following selections: 

5011i0589B0B63026E2E0.png

 

That would mean our XML would work out to be something along the lines of: 

 

<RepeaterData>
  <Version />
  <Items>
    <Item>
      <storeSections type="System.String">1;#10;#2;#20;#3;#30;#4;#40;#5;#50;#6;#60</storeSections>
    </Item>
  </Items>
</RepeaterData>

 

 

In a new workflow, I'm going to use the Query XML action to get a collection for any 'storeSections' elements I have in that Repeater Data XML: 

 

5012iA397B7BC148CE443.png

 

As of now, the value the var_storeSection_Collection = 1;#10;#2;#20;#3;#30;#4;#40;#5;#50;#6;#60;

 

But what we'd like is for it to be simply 10;20;30;40;50;60;

 

To get there, we'll Create a For Each Loop that will iterate over var_storeSection_Collection and store the index's value into a Single Line Text variable called var_storeSections:

5013iD0A4F43124A6D6B2.png

 

The loop is going to iterate over our single Collection value (because we're only working with a single Row of data in this example) and store its value in var_storeSections. this means that on our first pass, the value for var_storeSections = 1;#10;#2;#20;#3;#30;#4;#40;#5;#50;#6;#60

 

Using a Regular Expression Action, we're going to split the value of var_storeSelections into a NEW collection named var_storeSection_Collection using the following Expression: 

 

d*;#([dws]*;#)|d*;#(?=[dws]*;*?$)

 

 

5014iF47B6CD4CA78425E.png

 

this results in the value of var_storeSection_Collection = ;10;#;;20;#;;30;#;;40;#;;50;#;;60;

 

Now... that's a bit of a mess, but as you can see, it has stripped out all of the ID values! 

 

Next we'll use ANOTHER Regular Expression Action to replace any starting or ending semicolons and store the resulting value in a Multiline Text variable named var_storeSection_Collection_String, using the following expression: 

^;|;$

5015iB67F28ABC9321736.png

 

var_storeSection_Collection_String = 10;#;;20;#;;30;#;;40;#;;50;#;;60

 

NOW we have a string we can split into individual chunks to get some usable values. Using ANOTHER Regular Expression Action, we can split var_storeSection_Collection_String into individual values and over the messy values in our var_storeSection_Collection using the following expression: 

[;#]+

5016i46082F98A6722D34.png

 

var_storeSection_Collection = 10;20;30;40;50;60

 

Now we can loop over var_storeSection_Collection and do whatever it is we need to do with / to those values. 

I know that this is a bit convoluted, but I just wanted to knock out a reply real quick because this sort of thing can be frustrating if you've never dealt with it before. 

 

Overall your workflow will look something like this: 

5017i82905449E8B6A372.png

Badge +12

Instead of doing this long route....can you try and see below approach works for you or not (I didn't had time to test this)?

 

  1. In your repeating section you have lookup control, name it ctrl_lkup_Warehouse_Number
  2. Now add calculated control in that same repeating section and name it ctrl_calc_Get_Warehouse_Number
    1. In this control use parselookup(ctrl_lkup_Warehouse_Number)
    2. Since this is a control in repeating section, it will have it's own node
    3. Get the collections of the calculated control node and using 1 RegEx action split by ";

Reply