<iframe src="https://www.googletagmanager.com/ns.html?id=GTM-M74D8PB" height="0" width="0" style="display:none;visibility:hidden">
Loading
Skip to NavigationSkip to Main Content
0D54z000099rkFMCAYOkta Identity EngineWorkflowsAnswered2024-04-16T11:29:31.000Z2023-05-08T04:14:05.000Z2023-05-09T23:27:00.000Z

gpyyl (gpyyl) asked a question.

Convert 'Rows' from Table - Search Rows into one object/string

Hi Team,

 

I'm having a bit of trouble working with lists and building a single string output from a Table - Search Rows.

I have 'Table -Search Rows' return a list of objects with the format '{ "Countries": "AU, IT, XX..." } which I am trying to convert to the locations array for Managing Network Zones e.g.

` [{

"country": "AU",

"region": null

},{ "country": "IT",

"region": null

}, { "country": "XX",

"region": null

}]`

 

I have tried just about every combination of Object.ForEach, List.ForEach, Object.Map, Text.Compose and others I can think of and I cannot work out how to take the 'Rows' and convert to the above. I'm sure I'm just misunderstanding how to use one of these functions but any guidance wo


  • TimL.58332 (Workflows)

    I just realized I probably need to elaborate a bit as this is a POC and not a completed design. The first card in the Parent flow is a "Search Rows" This will return a list of rows. In a completed flow this would immediately be passed into a "For Each" type card to then be processed one level lower in the first Helper flow. Since this was just a test I leverage two flows and took a short-cut to remove the need of the third flow by using an Object-Get with a path of (zero position, dot, key name) which will provide the value of a fixed row (the first one since zero position was used).

     

    So a "completed flow would be:

     

    1) Search table rows > pass to foreach

    2) Helper that would process each row from the table, split the CSV, pass into reduce

    3) Helper that would do the reduce processing and return the final results to flow 2

     

    Flow 2 would be treated as the "Main" flow since flow 1 (the parent) would only be there for the initial data pull, no data can be passed back up to it since it is leveraging a for each.

     

    Expand Post
    Selected as Best
  • TimL.58332 (Workflows)

    @gpyyl (gpyyl)​ 

     

    Trying to make sure I understand your ask. The resulting data from a specific table cell is a CSV string containing multiple country values comma separated?

     

    Basically are you saying your search output is:

     

    [{"country":"CA"},{"country":"IT"},{"country":"US"}]

     

    or

     

    [{"country":"US,UK,IT,CA"}]

     

    And you just want to add another key:value pair to each?

    Expand Post
  • TimL.58332 (Workflows)

    @gpyyl (gpyyl)​ 

     

    So assuming its the first one (it makes the most sense but you never know) you will want to use a List - reduce.

     

    imageimageimage

    Expand Post
  • TimL.58332 (Workflows)

    If its the CSV one.. its exactly the same idea. But you would "split" the IT,US,CA to make a list. Pass that down into a reduce and slightly adjust the logic.

  • gpyyl (gpyyl)

    Hi @TimL.58332 (Workflows)​ 

    It's the csv one, I'm trying to follow this advice and examples you posted here https://support.okta.com/help/s/question/0D54z000091GbpPCAS/listreduce-is-errored-error-duplicate-input-key-memo?language=en_US but my reduce function seems to not be passing the list values or something.

     

    In main flow:

    Image is not available
     

    Helper flow:

    Image is not available
     

    Flow execution results:

    Image is not available
    Image is not available
     

     

    Expand Post
  • TimL.58332 (Workflows)

    @gpyyl (gpyyl)​ 

     

    So you need to ensure your data types are all correct. So on your Helper I can see they are not set correctly. In the CSV version "country" would be text as you have it. But memo needs to be a list of objects

     

    On the Parent side the Reduce output needs to be a list of objects (if it is not already defined that way). For the other 2 fields it will pickup what the Helper Flow has defined.

     

    imageimageimage

    Expand Post
    • TimL.58332 (Workflows)

      I just realized I probably need to elaborate a bit as this is a POC and not a completed design. The first card in the Parent flow is a "Search Rows" This will return a list of rows. In a completed flow this would immediately be passed into a "For Each" type card to then be processed one level lower in the first Helper flow. Since this was just a test I leverage two flows and took a short-cut to remove the need of the third flow by using an Object-Get with a path of (zero position, dot, key name) which will provide the value of a fixed row (the first one since zero position was used).

       

      So a "completed flow would be:

       

      1) Search table rows > pass to foreach

      2) Helper that would process each row from the table, split the CSV, pass into reduce

      3) Helper that would do the reduce processing and return the final results to flow 2

       

      Flow 2 would be treated as the "Main" flow since flow 1 (the parent) would only be there for the initial data pull, no data can be passed back up to it since it is leveraging a for each.

       

      Expand Post
      Selected as Best
  • gpyyl (gpyyl)

    @TimL.58332 (Workflows)​ 

     

    Awesome! Thanks heaps for your help, I appreciate it!

     

    I had to adjust slightly because I needed to gather all the rows into one call so instead of foreach after search rows I just reduced, then reduced in that helper function and I've achieved the result I'm looking for.

     

    Main flow:

    Image is not available
    First Helper:

    Image is not available
    Helper's Helper:

    Image is not available
     

    Thanks again!

    Expand Post
This question is closed.
Loading
Convert 'Rows' from Table - Search Rows into one object/string