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?

  Discussion posts and replies are publicly visible

Parents
  • 0
    Certified Lead Developer
    Hi,

    Please run the below code in expression rule:

    load(
    local!employee:{{id:23456,firstName:"xyz23456",lastName:"def"};{id:12345,firstName:"abc12345",lastName:"def"}},
    local!result:a!forEach(items:local!employee,
    expression: if((tointeger(fv!item.id)=12345),fv!item.firstName,{})),
    local!result
    )

    It should return "abc12345" which is first name for the employee having id as 12345.

    Thanks,
    Nitesh
Reply
  • 0
    Certified Lead Developer
    Hi,

    Please run the below code in expression rule:

    load(
    local!employee:{{id:23456,firstName:"xyz23456",lastName:"def"};{id:12345,firstName:"abc12345",lastName:"def"}},
    local!result:a!forEach(items:local!employee,
    expression: if((tointeger(fv!item.id)=12345),fv!item.firstName,{})),
    local!result
    )

    It should return "abc12345" which is first name for the employee having id as 12345.

    Thanks,
    Nitesh
Children
No Data