Skip to main content
September 28, 2021
Question

Is a!forEach cannot be written into saveInto?

  • September 28, 2021
  • 4 replies
  • 1 view

saveInto:{
                    if(or(isnull(local!searchDeleteUserRole),isnull(local!newUser)),{},
                    a!forEach(
                      items:rule!KONE_Development_CSE_TENDER_Rule(),
                      expression:a!localVariables(
                        local!tender_Id:fv!item.id,
                        local!status_Id:fv!item.statusId,
                        a!forEach(
                          items:rule!KONE_Development_CSE_TENDER_PHASES_Rule(),
                          expression:
                          if(fv!item.user=local!searchDeleteUserRole,
                          if(local!tender_Id=fv!item.tenderId,
                          if(not(or(local!status_Id=4,local!status_Id=3)),
                          {
                            a!save(target:ri!csetenderphases.user,value:local!newUser),
                            a!save(target:ri!csetenderphases.id,value:fv!item.id),
                          }
                          ,{})
                          ,{}),
                          {})
                        )
                      )
                    ),
                    )
                  },

This report " Expression evaluation error [evaluation ID = e8611:77009] : An error occurred while executing a save: Expression evaluation error: You must specify a variable to save into, such as ri!name << fn!sum. Received: List of Variant.". But i do write ri!csetenderphases.user as the value to save. What's wrong?

    4 replies

    stefanhelzle0001
    Brainy
    September 28, 2021

    The issue here is that the result of your foreach is a mix of empty lists and a!saves. You will need to remove the empty lists from your result.

    September 28, 2021

    so you mean i still can put a!save inside a!forEach loops right? Just empty list is problem

    stefanhelzle0001
    Brainy
    September 28, 2021

    Yes

    adityau269
    September 28, 2021

    Write your forEach() inside the value parameter of a!save() if business logic allows. That way, you can still return empty list for your forEach() and there wont be any errors.