Power Automate Compose Action

I have a compose action where I am trying to join constituent code descriptions. The way my expression is currently set up it is creating separate rows in my add a row to table for each constituent code description. I want it to join them by a comma.

This is my compose action expression:

join(createArray(items('For_each_-_Tributee_Constituent_Code_Self_Acknowledgee')?['description']), ',')

What am I doing wrong?

Best Answer

  • Alex Wong
    Alex Wong Community All-Star
    Tenth Anniversary Facilitator 5 Kudos 5 bbcon 2025 Attendee Badge
    Answer ✓

    not completely sure what your flow looks like, but I'm going to make some assumptions.

    You have a "get constituent codes" action on a constituent record id, that gives you a list (array) of objects of constituent code, which you want to have these code "join" as a one string separated by comma.

    this is what you need:

    image.png

    Note:

    1. Select action's From field should be the "value" dynamic content from the List constituent codes action
    2. Select actoin's Map field, you need to first click on the icon on the far right side, so it becomes ONE field, not TWO, then select the Constituent code dynamic content from the List constituent codes action, THERE IS NO FOR EACH LOOP needed here.

Answers

  • Bryce Howard
    edited May 12

    The array is whatever feeds the For_each_-_Tributee_Constituent_Code_Self_Acknowledgee loop. I think createArray(items('...')?['description']) creates single element array each loop. Joining array of one item. Without seeing your whole follow, there's probably two ways you can do it.

    Option 1: Select + Join using three actions.

    1. Select action place outside/after the For_each loop
      • From: the same that feeds Tributee_Constituent_Code_Self_Acknowledgee
        • Open your For_each, copy whatever is in "Select an output from previous steps"
        • for example: body('Get_Tributee_Constituent_Codes')
      • Map: item()?['description']
      • This should give you an output like: ["Code A", "Code B", "Code C"]
    2. Compose action (after the Select)
      • Inputs: join(body('Select'), ', ')
      • Output: "Code A, Code B, Code C"
    3. Add Row to Table
      • Reference: outputs('Compose')

    Option 2: One-liner

    • Use directly in Add Row to Table
      • Expression: join(xpath(xml(json(concat('{"r":{"d":', string(YOUR_ARRAY_SOURCE), '}}'))), '//d/description/text()'), ', ')
    • Replace YOUR_ARRAY_SOURCE with the same array that feeds Tributee_Constituent_Code_Self_Acknowledgee
  • @Alex Wong that was it! Thank you!

Categories