0

Display multiple dynamic choice items separated by returns rather than commas in Print

I have a table with a dynamic multiple choice field. I am trying print a record with the contents of the dynamic choice field displayed on separate lines. If I simply refer to the dynamic choice field (i.e. {'Field Name'}, the contents of the dynamic choice field display on the print document as comma separated, but no matter what I try I cannot display them on separate lines. I have tried using both the join() and replace() functions. Either one results in a blank field. Any suggestions?

8 replies

null
    • Fred
    • 1 yr ago
    • Reported - view

    Here is what I have:

    let x := for loop1 in numbers(dMC) do
            record(Cities,loop1).Name
        end;
    replace(concat(x), ", ", "
    ")
    

    Lines 1 - 3, uses the for loop command to go through each selection in the dMC field. Since each selection in the dMC is a record Id, I can use that in the record() command to get the Name of the City that I've selected. Here is where you would change Cities to match your appropriate table name and the Name to the appropriate field name.

    Then in Line 4, I use the replace() command to change each instance of comma and space into a carriage return. First I have then turn the variable x into text with the concat() command. The for loop command returns an array.

    Here is what it looks like in the form:

    Here is what it looks like in the Print layout:

      • tjdegrood
      • 1 yr ago
      • Reported - view

      Fred Thank you so much. It works as designed.

      • Fred
      • 1 yr ago
      • Reported - view

      tjdegrood When you get a chance, if you feel like you got what you needed please help others by marking the post "answered".

    • tjdegrood
    • 1 yr ago
    • Reported - view

    I meant to do that and forgot. I will now. BTW, the only issue I experienced is with choices where a comma is part of the choice (e.g., Company, Inc.). For now, I eliminated the commas.

      • Fred
      • 1 yr ago
      • Reported - view

      tjdegrood Yes, I did not take that into account. If I come up with a programmatic way I'll let you know.

    • Fred
    • 1 yr ago
    • Reported - view

    Here is a quick and dirty method of taking into account "," in names:

    let CRTN := "
    ";
    let x := for loop1 in numbers(dMC) do
            let y := record(Cities,loop1).Name;
            replace(y, ",", "\\")
        end;
    let z := replace(concat(x), ", ", CRTN);
    replace(z, "\\", ",")

    Lines 1 and 2, put the carriage return into a variable so the code below is easier to read.

    Lines 3 - 6 now adds a replace() command to swap "," to "\\". You can change this to anything you want, but I figure two \\ will not be used in common text.

    Line 7 is the first replace command to change the array into a string and the commas replaced with a carriage return.

    Line 8 then replaces the two \\ with a comma.

    • Ninox partner
    • RoSoft_Steven.1
    • 1 yr ago
    • Reported - view

    Hi Guys,

    FYI, here with a oneliner:

    join(for i in numbers(dMC) do
        record(Cities,i).City
    end, "
    ")

    Cities is the source table of the dMC field with one text field City.

    Fred tjdegrood

      • tjdegrood
      • 1 yr ago
      • Reported - view

      RoSoft_Steven Thank you so much. The code does exactly what I want.

Content aside

  • Status Answered
  • 1 yr agoLast active
  • 8Replies
  • 131Views
  • 3 Following