Issue with union

Hi ,

 

I have added working code and non working code.

I am trying to sort by paging info which i added in non-working code which i need to fix. I am sharing working code also where i am not doing any sorting on year which need to be required.

------------------Non Working Code after adding below code 
**local!subMAS_dataset: todatasubset(local!subDataset, a!pagingInfo(startIndex: 1,batchSize: - 1,sort:{{field: "year",ascending: false**
 
---Code Start---  
local!subDataset: rule!MAS_dataset(
    local!id,    
    "details"
  ).data,
 
  local!subMAS_dataset: todatasubset(
    {
      local!subDataset,
      a!pagingInfo(
        startIndex: 1,
        batchSize: - 1,
        sort: {
          {
            field: "year",
            ascending: false
          }
        }
      )
    }
  ),
  
  local!years: reject(
    fn!isNull,
    union(
      local!subMAS_dataset.year,
      local!subMAS_dataset.year
    )
  ),
  
  ----ERROR-----
  Could not display interface. Please check definition and inputs.
Interface Definition: Expression evaluation error at function 'union' parameter 2 [line 100]: Invalid index: Cannot index property 'year' of type Text into type DataSubset
  ----Code End-----
  
  
  ------Working code without sorting year------
  ----Code Start-----
  local!subDataset: rule!MAS_dataset(
    local!id,    
    "details"
  ).data, 
  
  local!years: reject(
    fn!isNull,
    union(
      local!subDataset.year,
      local!subDataset.year
    )
  ),
  
  "NO ERROR"
  ----Code End-----

 

May i know the reason and how to fix that . Please help me on that.

ERROR- Could not display interface. Please check definition and inputs. Interface Definition: Expression evaluation error at function 'union' parameter 2 [line 100]: Invalid index: Cannot index property 'cycleYear' of type Text into type DataSubset

  Discussion posts and replies are publicly visible

Parents
  • Hi Saurav,

    Please use the below code , It will work for you.

    load(
    local!subDataset: {
    {
    id: 1,
    year: "2017"
    },
    {
    id: 2,
    year: "2019"
    }
    },
    local!subMAS_dataset: todatasubset(
    local!subDataset,
    a!pagingInfo(
    1,
    - 1,
    a!sortInfo(
    field: "year",
    ascending: false
    )
    )
    ).data, /* Best practice to take the data from datasubset */


    local!years: reject(
    fn!isNull,
    union(
    index(
    local!subMAS_dataset,
    "year",
    null
    ),
    index(
    local!subMAS_dataset,
    "year",
    null
    )
    )
    ),
    local!years
    )

     

    Thanks
    Siva Chimata

Reply
  • Hi Saurav,

    Please use the below code , It will work for you.

    load(
    local!subDataset: {
    {
    id: 1,
    year: "2017"
    },
    {
    id: 2,
    year: "2019"
    }
    },
    local!subMAS_dataset: todatasubset(
    local!subDataset,
    a!pagingInfo(
    1,
    - 1,
    a!sortInfo(
    field: "year",
    ascending: false
    )
    )
    ).data, /* Best practice to take the data from datasubset */


    local!years: reject(
    fn!isNull,
    union(
    index(
    local!subMAS_dataset,
    "year",
    null
    ),
    index(
    local!subMAS_dataset,
    "year",
    null
    )
    )
    ),
    local!years
    )

     

    Thanks
    Siva Chimata

Children