While loop implementation!

  
Hello dear experts!

I need to loop search for items(that I have received from the recipe), which are the ingredients of another recipe. But I'm not sure it can be done without while do loop. Any ideas?









Thanks for your attention!

not sure why you need a while-loop for that.
what do you actually need to accomplish?


a while-loop in Outsystems is accomplished with an if-statement.
J. wrote:
not sure why you need a while-loop for that.
what do you actually need to accomplish?


a while-loop in Outsystems is accomplished with an if-statement.
as you can see IF did not work in my case. not all while-loop can be replaced by IF
No I cannot see, because I only see a screen with some actions.

I do notice that it's not a good design pattern to have 4 -inner loops.

Furthermore, I think it's easier checked with some advanced queries..

Hey J!

Did you notice you can actually click the image for a full screenshot? I still have trouble figuring out the problem, but it indeed seems that SQL could be used to simplify some of it...

@TRUSTN01 what is the error you get on top of that underlined loop? Could you perhaps post the module, or a subset of it, it normally helps a lot...

Cheers!
Tthank you for your help!

I will try to explain the problem.

I have recipes - they consist of "out item" - item which i will get after using the recipe and "in Items" - items, which need to use this recipe. So i need to find chain which contains at least 2 sequences. but I do not know the depth of sequence. sequence: "outitem" which used as "initem" => this "initem" used in next recipe to get next "outitem". So i have to check condition to exit(if last "outitem" is not an "initem" for another recipe) loop. I apologize for my English though)
Ok,

so basically it's an hierarchy you want to figure out.

either create a recursive way with actions to get all the chains with more than 2 sequences.
it's doable in outsystems, but not easy.

or you can check out the CTE-functionality in sql, since it probably is a different way of how to order employees and managers.
basically you need to figure out the indexes > 2

WITH
  cteReports (EmpID, FirstName, LastName, MgrID, EmpLevel)
  AS
  (
    SELECT EmployeeID, FirstName, LastName, ManagerID, 1
    FROM Employees
    WHERE ManagerID IS NULL
    UNION ALL
    SELECT e.EmployeeID, e.FirstName, e.LastName, e.ManagerID,
      r.EmpLevel + 1
    FROM Employees e
      INNER JOIN cteReports r
        ON e.ManagerID = r.EmpID
  )
SELECT
  FirstName + ' ' + LastName AS FullName,
  EmpLevel,
  (SELECT FirstName + ' ' + LastName FROM Employees
    WHERE EmployeeID = cteReports.MgrID) AS Manager
FROM cteReports
ORDER BY EmpLevel, MgrID