Need to filter the manually retrieved datasubset

Hi,

I've retrieved the data manually and changed that into datasubset. Now, I need to add the filter in that datasubset.

todatasubset(
      a!forEach(
        items: union(
          rule!ISS8_getAllRequests().applicationName,
          rule!ISS8_getAllRequests().applicationName
        ),
        expression: {
          rule!ISS8_getRequestNumbersByAppName(
            fv!item
          )[1]
        }
      )
    )

Kindly suggest me to find out this implementation. Thanks for your response!

  Discussion posts and replies are publicly visible

  • Hi Manju

    Please can you elaborate on your requirement - what data are you filtering and on what criteria?

    (separately - I see you're using the [1] subscript in your code, presumably because your rule is returning an array. In your rule you can cast the result so that it isn't an array anymore which is a better method)

  • Thanks for your response!

    Yes, actually I have many entries under one application name. Here I need to show latest entry in each application. So I've applied query condition by application name and sorted by request number in descending manner and fetching first index of that array. So, it will show the last entry of the each application present in entire database.

  • Based on your response of attempting to find the latest entry, if you could create a view that does this for you.  Assuming a table (TBL_A) has columns (ID [PK], APP_ID,....) and you want to just get the rows for the latest entry for each APP_ID (latest being the greatest ID associated) then you could do a simple join like this:

    Select A.* from TBL_A A INNER JOIN (SELECT APP_ID, MAX(ID) LATEST_ID from TABLE_A group by APP_ID) X on A.APP_ID = X.APP_ID


    alternately, to do this in sail and the format you are using, you could do something like the following:

    todatasubset(
        reject(
        isnull(),
          a!forEach(
            items: union(
              rule!ISS8_getAllRequests().applicationName,
              rule!ISS8_getAllRequests().applicationName
            ),
            expression: {
            if(<condition>, null,
              rule!ISS8_getRequestNumbersByAppName(
                fv!item
              )[1]
              )
            }
          )
          )
        )

    note that, depending on the returned structure, you may need to use flatten() to remove a dimension from the array. 

  • Hi,

    I've used this SQL Query function and created view. Now I'm able to filter. Thanks for your response!