Skip to main content
September 30, 2022
Question

Writing the code in loop

  • September 30, 2022
  • 6 replies
  • 0 views

I need to write below code in a loop :

"<table border=""1"" style=""width:100%""><style>


</style>"&
"<tr><td>" & ri!headerList[1] & "</td><td>
"& ri!cdtType[2].commentDate&"</td>
</tr>"
&"<tr><td>" & ri!headerList[2] & "</td><td>
"& ri!cdtType[1].comment_txt &"</td>
</tr>"



&"</table>",

 I want a looping only for 

"<tr><td>" & ri!headerList[1] & "</td><td>
"& ri!cdtType[2].commentDate &"</td>
</tr>"

Can anyone let me know please

    6 replies

    September 30, 2022

    You have to create a rule for this in which you can apply looping

     

    a!localVariables(
      local!data: { 1, 2, 3, 4 },
      local!data2: { 1, 2, 3, 4 },
      local!data_count: length(local!data2)+1,
      a!forEach(
        items: local!data,
        expression: concat(
          "" & fv!item & "
    " & local!data2[local!data_count - fv!index] & "
    "
        )
      )
    )

    September 30, 2022

    Thank you so much  ujjwal, It was helpfull.

    In my case I have a cdt as local!data2 and I want different field name for every row.

    1

    Cdt.id

    2

    Cdt.name

    3

    Cdt.2ndname

    September 30, 2022

    In this case, I think you should create your own logic which would be something like this 

    a!localVariables(
      local!data: { "Name","Date","Comment"},
      local!data2: {
        a!map(
          name:"Ujjwal",
          date:now(),
          comment:"I want to learn Appian"
        ),
        a!map(
          name:"Ujjwal",
          date:now(),
          comment:"I want to learn Appian"
        ),
      },
      local!data_count: length(local!data2),
      a!forEach(
        items: enumerate(local!data_count),
        /*expression: local!data_count-fv!index*/
        expression: concat(
          "" & local!data[1] & "
    " & index(local!data2,fv!index,"name",{}) & "
    "&
    "" & local!data[2] & "
    " & index(local!data2,fv!index,"Date",{}) & "
    "&
    "" & local!data[3] & "
    " & index(local!data2,fv!index,"Comment",{}) & "
    "
        )
      
    ))