Help writing single column from multiple selected rows as delimited list in a text field

I’m recreating a SN Selection slide out in a UD Entry screen and my last step after the user selects one or more serial number is to write all the selections into a single text box (with a comma delimiter) upon clicking the OK button.

I have an event with a dataview-condition widget and a related iteration event–which I think is the correct way to go about this based on a few other posts–however, I’m having a few issues getting it to work.

  1. In one setup, debugging shows it iterating how many times equal to how many rows are selected, but in every iteration it’s only pulling the last row. On top of that, I cannot get it to write even that last row to my UD field (UD100 table).
  2. In the second setup, I can get it to write to my UD field, except it’s only iterating once then stopping.

Here’s my setup for scenario 1:


Value text:
"{SerialNumbersAvailable.SerialNo_SerialNumber}, "

And the console writing (SN 000836 is the last row selected):


Here’s my setup for scenario 2:

The iteration event is the same as in scenario 1 above.

What’s written to my UD100 field that I’m trying to update:

And the console writing (SN 001001 is the last row selected):


Questions:
1. What am I doing wrong? Is this even the way to go about this?
2. Assuming this is the correct way to do it, what’s the correct way to get it to write the SN from each selected row into a single field?

In your row update “value”… can you try "{matches.SerialNo_SerialNumber}, "

When you do the dataview-condition, it goes through your SerialNumbersAvailable dataview and makes a virtual copy of all rows which passes your condition and adds them to your “matches” dataview.

~~ can you verify in debugger, looking at your dataviews, that you’re getting the correct rows in your matches dataview? ~~

Your iterative event is then going to work through the rows from your “matches” result set. So, I think you need to get your “values” from there.

Because your current value is referencing:
"{SerialNumbersAvailable.SerialNo_SerialNumber}, "

Its getting the value from THAT dataview and its just going to use the last row selected there. At least, that’s why I think you keep getting the same value in your Scenario 1.

That being said… I don’t know if you’re going to get a concatenated list, or if it is just going to overwrite the value you’re putting in matches.SerialList_c multiple times. I’ve never played with that to build a list. But at least you can see if the value changes with each iteration in debugger.

1 Like

Ok, I thought I had tried that, but apparently not. That does correctly iterate through and pull the value from each row. It’s still not writing anything to my UD100 column, though.

Edit:

I am.

Well, it does look like it is updating your matches.SerialList_c column.

Not, concatenating… but updating.

What is your textbox bound to?

My text box is bound to UD100.SerialList_c, where I ultimately need the string saved to.

I did notice that it was updating it, so I tried doing something like this in my rowupdate:

"{matches.SerialList_c} {matches.SerialNo_SerialNumber}"

But it updates the SerialList like “undefined 000400”

I tried changing the binding to matches.SerialList_c and it does then write to my text box, but then only the last row in the iteration.

Maybe setup a function to do the concatenation?

Yeah, the idea that I may have to do that has been rattling around in the back of my mind. I’ve done several of them with help from others/in a class, but I still don’t understand them enough to ever know where to start with designing one. And I know zero C#, so that makes them more daunting to try to tackle.

1 Like

Can you try a row-update expression of:

{UD100.SerialList_c} === '' ? {matches.SerialNo_SerialNumber} : {UD100.SerialList_c} + ', ' + {matches.SerialNo_SerialNumber}

I’ve never tried to do an “if check” in a row update… but row updates are javascript so, if that works… it will check to see if UD100 has a value, if not, it’ll add the first serialnumber. If it does, I’m hoping it will update UD100.SerialList_c by taking the existing value of UD100.SerialList_c and add the next serial number.

1 Like

you’re my guinea pig :rofl:

2 Likes

I’ve created exactly two so I’m far from any expert either. This one doesn’t sound too daunting as it appears you already got getting the serial numbers in a dataset working. But it’s just a thought.

Got me thikning, what is the javascript for concatenate strings? Google says it’s:

str1 + ", " + str2; 

So perhaps try something like: “{SerialList_c}” + ", " + “{matches.SerialNo_SerialNumber}”

Am I entering it correctly? It won’t save it as I enter and reverts back to last saved entry.

Try Expression (javascript)… not value (json)

Yep, you clearly wrote “expression.” …trying.

2 Likes

one more try… I think UD100.SerialList_c could be null. So it may be trying to equate null === ‘’ and chocking on it.

Try this one:
({UD100.SerialList_c} || '') === '' ? {matches.SerialNo_SerialNumber} : {UD100.SerialList_c} + ', ' + {matches.SerialNo_SerialNumber}

Sorry for the experimenting… I’m not even sure this is going to work. :person_facepalming: :rofl:

1 Like

haha, no worries! Experimenting is what I’ve been doing on this since yesterday.

Would the expression need to end with a semicolon perhaps, as in @Randy’s example above? I was getting a token error with his example, too, until I added the semicolon.

Nope, with or without the semicolon still get an error:

image

1 Like

Well, since we know (or think) UD100.SerialList_c is null… let’s bail on the || and just check for null.

{UD100.SerialList_c} == null ? {matches.SerialNo_SerialNumber} : {UD100.SerialList_c} + ', ' + {matches.SerialNo_SerialNumber}

1 Like

nothing like throwing darts blind folded, haha.

dave franco darts GIF by 20th Century Fox Home Entertainment

3 Likes

Ok, maybe some progress.

I try this:
"{UD100.SerialList_c}" + ", " + "{matches.SerialNo_SerialNumber}";

And I don’t get the “undefined”, instead I get blank and the serial number for that row, because that UD column is blank.

If I replace UD100 with matches (like below), then the ‘undefined’ is back (and I even added in a data-commit widget after my row-update widget).

"{matches.SerialList_c}" + ", " + "{matches.SerialNo_SerialNumber}";