App Connect

 View Only
Expand all | Collapse all

Trying to concatenate strings during a loop in app connect designer

  • 1.  Trying to concatenate strings during a loop in app connect designer

    Posted Tue July 11, 2023 09:41 AM

    Hi,

    I'm trying to concatenate a certain string with some values on each iteration of a for each loop.

    My attempt is setup like this:

    • I have a set variable connector that sets the variable 'commitString' to an empty string (I also tested using a random string).
    • Then I have the for each loop which gathers commits and their messages
      • In this loop, I have another set variable connector, that sets the variable 'commitString' to 'commitString message' (where message is the commit message of the commit is the iteration of the loop

    At the end of the flow, my string is always equal to the initial value I put for the string. I also tried changing my second set variable to change it to "testing123", which helped me understand that this connector is not doing anything at all (commitString was still the initial value)

    With the help of some logging connectors, I have verified that my for each loop does have iterations (4 of them) and that their commit message is gathered correctly.

    So finally, my question, does anyone know how I can fix this issue or how to do it?

    fyi, I know the usecase for this is confusing, I'm just testing the software out so it's not an actual usecase.

    I'll attach some pictures of my initial setup attempt for information:



    ------------------------------
    Wannes Vande Cauter
    ------------------------------


  • 2.  RE: Trying to concatenate strings during a loop in app connect designer

    Posted Tue July 25, 2023 05:20 AM

    Hello,

    Sorry for the delay in answering  your query.

    For your use case, you need to use the output part of the for each node that acts as an accumulator for data from each iterand.

    So iterating on github commits, I added an element to the output that stores the message of each commit

    with that output, in the next node after ForEach I can process the output of the foreach with the accumulated data from each iterand.
    For example, here I am testing the output from the forEach and you can see the output. 
    Also, you might want to use the testing function https://www.ibm.com/docs/en/app-connect/saas?topic=testing-designer-flows rather than the log nodes
    I hope this helps.
    Thanks,
    Doina


    ------------------------------
    Doina Klinger
    ------------------------------