Is there a way to group array data together into single array item?

Certified Associate Developer

Hello All,

Do we have any logic exists for grouping the array of data's into single array item and so on? Here is a quick example

 

Suppose my CDT has total 10 items. Now I want to reconfigure this item in a way that a second variable has 5 items grouped together as an array of 1 and another 5 items will be grouped as an array of 2. Any suggestion here would be appreciated

  Discussion posts and replies are publicly visible

  • 0
    Certified Senior Developer
    Can you please explain with some sample data?
  • 0
    Certified Lead Developer
    Hi are you trying to split a cdt array into two parts? Or do you want to merge 2 cdt into one?

    Can you please elaborate your use case
  • 0
    Certified Associate Developer
    in reply to aloks0189
    Sure,Let me brief the scenario. So what happening here is I have a cdt which consists of multiple values for launching a job. Currently we are planning to build an application where users can launch jobs in bulk. Hence we are using export cdt to excel smart service for taking users input. Now once user uploads the file after adding required fields in the excel file. The final cdt have values for all the jobs that need to be launched. i.e lets say user wants to launch five jobs at a time then my cdt consists of array for all the five jobs. As we have to send the values one by one in order to launch successive jobs. I need to group required data for a job into single array. For example

    suppose below fields are required to launch a job

    ID Name Parameter
    1 abc pqr
    2 lmn xyz


    So as you can see the above information given is for launching two jobs as we have two rows but the cdt which consists of this data has an array size of 6. So I want to reform another cdt which stores values of first row in a single array position and values of second row in another array index and by that way I can send the parameters one by one to launch my jobs.
  • I am not sure how exactly you want it to group, I have placed a sample code below.  take a look into it and let me know if it helps

    with(

     local!data:{1,2,3,4,5,6},/*Data list*/

     local!columnCount:3,/*Number of columns*/

     local!column: a!forEach(

       enumerate(local!columnCount),

    index(local!data, where(  apply(

       mod(_,local!columnCount),enumerate(count(local!data)))=fv!item),{})

       ) ,

    local!column

    )

  • Vivek, Are you using "Parse Excel to CDT" or "Export CDT To Excel", if you are using Parse Excel to CDT then store your output in multiple type cdt.. it will gives you row wise entries in cdt.