Skip to main content
September 20, 2023
Solved

Is there a mistake in this forEach to get all data by id. Using rule

  • September 20, 2023
  • 9 replies
  • 0 views

a!forEach(
items: pv!id,
expression: a!save(
rule!Test_getDossierByDossierId(
dossierId: fv!item,
pagingInfo: a!pagingInfo(1, - 1)
),
pv!id
).data
)

    Best answer by herver5127

    I choose the first way because my rule!Test_getDossierByDossierId accepts one type rule input : dossierId

    9 replies

    stefanhelzle0001
    Brainy
    September 20, 2023

    Multiple:

    - Using a process variable in an a!save() seems not correct

    - What is that pv!id in line 8 doing?

    - Querying data in a loop is a bad performing anti-pattern

    September 20, 2023

    In fact, I want to make a loop in a process variable "pv!id" to retrieve all data 

    dhananjayk3480
    September 20, 2023

    Then just run loop like below, don't do a!save. Because you just need data

    a!forEach(
      items: pv!id,
      expression: rule!Test_getDossierByDossierId(
        dossierId: fv!item,
        pagingInfo: a!pagingInfo(1, - 1)
      ).data
    )

    Or if you rule rule!Test_getDossierByDossierId accepts multiple type rule input dossierId then you don't need to run loop

    rule!Test_getDossierByDossierId(
      dossierId: pv!id,
      pagingInfo: a!pagingInfo(1, - 1)
    ).data