Which operator should I use to return certain records based on logged in status?

I am using a!queryProcessAnalytics function to fetch the data from the portal report, and a!queryLogicalExpression function to filter the data, however one of my column say "c9" is having multiple data like list of user, I need only those records from my portal report where "c9" contains logged In user. Which operator I should use?

OriginalPostID-192337

  Discussion posts and replies are publicly visible

  • @ravir Hi, to the best of my knowledge, here goes the solutions:

    Solution 1:
    Try using the 'includes' operator. I am not sure how far this works, as we are dealing with a string which is result of concatenated array variable. I would like to suggest you to check the accuracy of results by testing the same.

    Solution 2:
    Add a column of Boolean type, in the report. Let's call the newly added column as 'Is logged in user part of list?'. Configure its value like this - If the logged in user is part of user list, then set the value as true, else set it as false. Technically speaking, the column's value should be fn!contains(, fn!loggedInUser()).
    Now when you invoke a!queryProcessAnalytics(), apply the filter on the 'Is logged in user part of list?' column. That is, get only those records from report whose value is true for 'Is logged in user part of list?' and this accomplishes your use-case. Just to let you know, this approach works for sure without any issue.

    Please do let us know in case of any follow up questions.
  • I have tried with includes operator however that was not working
  • @ravir Yep, Solution 1, that is, usage of 'includes' operator shouldn't work as per my knowledge. Solution 2 should help you accomplish the use-case. Try Solution 2 and do let us know if there are any issues.

    And re the question 'Which operator I should use?' - I don't think any other operator can aid you in accomplishing the use-case.
  • Yeah, there should be a operator called "Contains". :)

    I will try second solution and let you know.
    Anyway Thank you!!
  • Hi Ravi,
    You can try with the "in" operator for filtering on the list of users.
  • @sonalk Just to let you know, 'in' operator doesn't work at all. If you take a look at the use-case keenly, the column in the report looks as follows:


    Example 1: Let's assume that a column by name 'Users' contains following values for 4 rows in a report:
    Users
    -------
    user1
    user1;user2
    user3;user2;user1;user4
    user5;user1

    I don't think applying the 'in' operator will result you in the desired content. Because here each value in the column is in-turn a list of values in concatenated format, that is, 2nd row is a string combining two values, 3rd row is a string combining five values and so on.

    For instance, let's say, for a filter, we have used the 'in' operator and fed the value as 'user1'. Then we get only one row, that is the first row from the above mentioned example. The remaining rows will be skipped because, second, third and fourth rows which should be present in the result has concatenated values by joining with other set of users.

    Take a look here, this is how the filter will be applied, and you can understand that the filter won't work at all:
    (user1) in (user1)
    (user1) in (user1;user2)
    (user1) in (user3;user2;user1;user4)
    (user1) in (user5;user1) (We need to make a note here that user5;user1 is a string, and trying to filter the user1 in it fails and this row won't be returned. And this is also a reason, why a user has desired for contains())

    As specified by you, the 'in' operator does good, only when the column holds a single value against each row in the report. Have a look at the example as follows:

    Example 2:
    Users
    -------
    user1
    user1
    user5
    user4

    So simply speaking, the 'in' operator does good when filtering the list(as specified in Example 2), but that's not the case when the each row in-turn holds a list in a concatenated format(As mentioned in Example 1).

    Even the solution suggested by me is quiet simple just because of the requirement that the filter should be based on loggedInUser. Else accomplishing the use-case when the user value is dynamic makes the solution highly complex.
  • @ Sikhi : Apologies I thought it should work here so suggested the same, but got it clear with your explanation.
    Thanks for the explanation.
  • Hi sikhivahans,
    I am trying with the second solution, unfortunately I am not getting the loggedInUser function in expression editor, however I made a expression rule with a parameter of taskAsignee and returning the Text YES or NO based on it found loggedInUser or not, but this seems not working. It showing me the blank value.
  • Yes I got that.

    =contains({touser(tp!assignees)},touser(rule!MyRule()))

    where the rule MyRule() is just returning the loggedInUser().

    Thanks sikhivahans for your answers.
  • @ravir Just to let you know, tp!assignees is of type User or Group and is able to hold multiple values. Whenever we deal with this data type, that is User or Group, use fn!touser() to return users and use fn!tointeger() return groups.

    No problem and glad that you got the solution.