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
  • You can use the filter() function.
    First you need to create a rule which takes A .one Employee CDT as input B. the id/name to filter on.
    This rule should return true if the EmployeeCDT.name is equal to given givenName or EmployeeCDT.id equal to id.
    Example:

    local!filteredEmployee: filter( rule!returnTrueIfEmployeeHasId( _, 12345) , ri!arrayOfEmployeeCDT ).

    Then just access the name using local!filteredEmployee.name


    Here the rule returnTrueIfEmployeeHasId is assumed to be created already.
    It has some condition like this:
    ri!cdtEmployee.id = ri!inputId

    Note: you could extend this pattern and create child rules for each of the filters possible. (say filter by name, filter by id etc.)

Reply
  • You can use the filter() function.
    First you need to create a rule which takes A .one Employee CDT as input B. the id/name to filter on.
    This rule should return true if the EmployeeCDT.name is equal to given givenName or EmployeeCDT.id equal to id.
    Example:

    local!filteredEmployee: filter( rule!returnTrueIfEmployeeHasId( _, 12345) , ri!arrayOfEmployeeCDT ).

    Then just access the name using local!filteredEmployee.name


    Here the rule returnTrueIfEmployeeHasId is assumed to be created already.
    It has some condition like this:
    ri!cdtEmployee.id = ri!inputId

    Note: you could extend this pattern and create child rules for each of the filters possible. (say filter by name, filter by id etc.)

Children
No Data

 Discussion posts and replies are publicly visible