Fetch only rows from CDT

Hi Everyone,

Is there a way we can fetch few rows from process variable with type CDT.

I have process variable lets say pv!ABC_cdt, if i want to gets 1st to 10th rows or 20th row to 30th row either i can convert that to todatasubset by adding paging(1,10) or paginf(20,10)  or i have to map the indexes pv!ABC_cdt[{1,2,3,4,5,6,7,8,9,10}]. in my case i cannot use to data subset.. is there any dynamic way where i can get the values by passing "from" and "to" rows.

 

My realtime use case is like below:

I have a data in process variable  i want to display the data in multiple editable grids by dividing the data and i cannot use multiple process variables. even though its multiple grids the data should be stored in single process variable which i'm passing to it.

  Discussion posts and replies are publicly visible

  • Hi karthik,

    Just write a expression rule and pass your CDT and pass two more variables "from" and "to" like below :


    load(
    local!CDT: {
    {
    ID: "12",
    Name: "ABC"
    },
    {
    ID: "13",
    Name: "ABC"
    },
    {
    ID: "14",
    Name: "ABC"
    },
    ------ n times
    },
    local!data: a!forEach(
    items: local!CDT,
    expression: if(
    and(
    fv!index >= ri!from,
    fv!index <= ri!to
    ),
    fv!item,
    "useLessData"
    )
    ),
    remove(local!data,wherecontains("useLessData",touniformstring(local!data)))
    )

    So now replace local!CDT with your actual array and pass "from" and "to" . Now suppose you sent some wrong index values then we will fill the array with "useLessData" and after that we will remove this as well.

    Regards
    Abhay Giri
  • Hi,

    You can use Index and Enumerate function to get the data accordingly,
    for example

    local!StartIndex : 10
    local!BatchSize : 5

    index(
    pv!ABC_cdt,
    local!StartIndex + enumerate(local!BatchSize),
    null
    )

    hope this help
  • 0
    Certified Associate Developer
    I think you can try this

    load(
    local!start:1,,
    local!end:10,

    local!val:index(
    PV!ABC_cdt,
    rdrop(local!start+enumerate(local!end),local!start-1)
    )

    Note: you have to use rdrop because if you will change your start value to something else then it will give you index error as it will count from start to end number of characters. Hence the above code will work perfectly fine in any use case