How to query on local data?

I have an array of of CDT which have local data stored in it. Now I have to fetch data from the array based on some certain condition.
For example, I have a CDT named "Employee" with fields firstName, lastName and employeeId. Now I want to get the firstName of the employee whose employeeId is 12345.
How to achieve that?

Parents
  • Hi,

    You can make use of wherecontains() and index() functions,

    load(
    local!employee:{
    {employeeId:12345,firstname:"abc"},
    {employeeId:1345,firstname:"ghj"},
    {employeeId:12345,firstname:"xyz"}
    },
    local!indexes : wherecontains(12345,tointeger(local!employee.employeeId)), /*this will return the index of the row which has this employeeId.*/
    local!data:index(local!employee,local!indexes,{}), /* this will return data at that indexes */
    local!data
    )

    Try above code.

    Thank you.
Reply
  • Hi,

    You can make use of wherecontains() and index() functions,

    load(
    local!employee:{
    {employeeId:12345,firstname:"abc"},
    {employeeId:1345,firstname:"ghj"},
    {employeeId:12345,firstname:"xyz"}
    },
    local!indexes : wherecontains(12345,tointeger(local!employee.employeeId)), /*this will return the index of the row which has this employeeId.*/
    local!data:index(local!employee,local!indexes,{}), /* this will return data at that indexes */
    local!data
    )

    Try above code.

    Thank you.
Children
No Data

 Discussion posts and replies are publicly visible