Datablaze and Repeater

Hello,

I have a question regarding reading table information from within a repeater.

I have populated a table with 4 columns (a,b,x,y), each with various rows (4 in this example).

I have a repeater, inside which I would like to output dynamic form-paragraphs with the output of columns "x" and "y", separately. These outputs would be based on columns "a" & "b" which I would like to be able to adjust separately within each repetition.

{if: countdx=1; trim=left}{Letters="a)"}{endif}
{if: countdx=2; trim=left}{Letters="a),b)"}{endif}
{if: countdx=3; trim=left}{Letters="a),b),c)"}{endif}
{if: countdx=4; trim=left}{Letters="a),b),c),d)"}{endif}
{if: countdx=5; trim=left}{Letters="a),b),c),d),e)"}{endif}
{if: countdx=6; trim=left}{Letters="a),b),c),d),e),f)"}{endif}

Count: {formmenu: default=1; 2; 3; 4; 5; 6; name=countdx}

{dbselect: SELECT A, B, X, Y FROM Example WHERE A = @a AND B = @b; space=2j8mrZ2X7v9KckLeroLzgS; menu=no; multiple=no}

{repeat: for Letter in split(letters,",")}

{=letter} {formtext: name=A; default=}{formtext: name=B; default=}

{formparagraph: name=X; cols=49; rows=5}

{formparagraph: name=Y; cols=49; rows=5}

{endrepeat}

In the db-reader, which is outside the repeater, I have set 2 conditions, that A=a and that B=b, this does produce the desired outcome of having "x" and "y" produced in form-paragraphs that I can adjust.

  • However, each repetition is the same (non-distinct). Changing variables "a" and/or "b" changes each repitition.

How would I be able to adjust in order to produce separate instances of "reads" from the same table?

  • I have put the table (db-reader) within the repeater which works, however this slows my process down rather significantly and as such, I would like to keep the db-reader out of the repeater.
  • I have also been able to produce separate instances of non-modifiable output using map and filter commands but this does not produce the desired results of having form-paragraphs I can adjust.

Thank you for the help in advance!

Hi @Andrei_Aldea1

One workaround here is to use the filter() function + conditionally initialize both variables x and y if their initial values are both empty as follows:

{if: countdx=1; trim=left}{Letters="a)"}{endif}
{if: countdx=2; trim=left}{Letters="a),b)"}{endif}
{if: countdx=3; trim=left}{Letters="a),b),c)"}{endif}
{if: countdx=4; trim=left}{Letters="a),b),c),d)"}{endif}
{if: countdx=5; trim=left}{Letters="a),b),c),d),e)"}{endif}
{if: countdx=6; trim=left}{Letters="a),b),c),d),e),f)"}{endif}

Count: {formmenu: default=1; 2; 3; 4; 5; 6; name=countdx}

{dbselect: SELECT A, B, X, Y FROM Example; space=7Iu63X2c8oC1L4N2OWgSpo; menu=no; multiple=yes; name=results}

{repeat: for Letter in split(letters,",")}

{=letter} {formtext: name=A; default=}{formtext: name=B; default=}
{entry=catch((filter(results, (e) -> e["a"]=A and e["b"]=B))[1], ["x": "","y":""])}
{if: entry["x"] <> "" and entry["y"] <> ""}
{if: x="" and y=""}
{x=entry["x"]}
{y=entry["y"]}
{endif}
{formparagraph: name=X; cols=47; rows=5}

{formparagraph: name=Y; cols=49; rows=5}
{endif}

{endrepeat}

Please give it a try and let me know if that helps.

Thank you very much, this strategy definitely help.

1 Like

Just a follow-up question:

I was wondering if it’s possible to identify when variables change (i.e. a dropdown menu variable, or any variable for that matter) and then perform the same action/execute same line of code each time the variable changes?

Hi @Andrei_Aldea1.

Can you please provide more details about what you're trying to accomplish? I'd like to understand what specific action you need to perform when the dropdown menu or variable changes. This information will help me provide a more targeted solution for your needs.