The function runtimetype() returns "list of user or groups-127" instead of either "user-4" or "group-5"

Certified Senior Developer

Hello,

I am trying to get the details from the task report.

My task report is by Process model and i'm trying to get the assignee of each task. I am facing the issues as below:

1. With filter: 

filters:{

a!queryFilter(
/*c4 is the owner*/
field: "c4",
operator: "in",
value: loggedInUser()
),
a!queryFilter(
/*c6 is the task assignee*/
field: "c6",
operator: "in",
value: loggedInUser()
)
}

When my task is assigned to individual user, the assigned task filter above works and shows me all the tasks assigned to the user.

But when the task is assigned to a group and the loggedin user is a member of the group, the task is not shown to the user.

I have tried the operator "includes" instead of "in". In this case, all the tasks are shown, irrespective of the user being the member of the group or not.

2. the runtimetype()

I want to display the assignees name(either group or user) in the grid. When i try the following code which i referred from the documentation.

if(
runtimetypeof(fv!item) = 4,
/*User is type 4; group is type 5*/
user(fv!item, "firstName") & " " & user(fv!item, "lastName"),
/*Adding char(10) adds line breaks to the list of names*/
group(fv!item, "groupName")& char(10)
)

the flow always goes to the else part i.e. the group function. I tried displaying the runtimetypeof(fv!item) and the value comes as 127 instead of 4 or 5. 

Kindly help me in resolving this issue.

I want to just display the tasks pending with the user. either pending individually or to the group it belongs to.

  Discussion posts and replies are publicly visible

  • 0
    Certified Lead Developer

    For your #1, your expectations about it filtering for group membership will need to change, because it won't work this way.  The query function has no particular insight into who is a member of what group, it is merely filtering on the face-value assignment(s), be it usernames or groups by id.  Special care must also be taken since the assignees for a task can technically include any number of users and groups in any mixture, even though this isn't done very often.  Furthermore, the query functionality is fairly picky about the types you're trying to use for filtering, which for me in the past has caused even simple filters that seemed like they shoud work to actually do nothing.  My personal workaround for this has traditionally been to add an extra column that i wrap in "tostring()", which causes the list of assignees to evaluate as a flattened single text value, and then you can potentially do some query trickery to query within this value.  

    This still won't help you query on group-assignments that your chosen user is a member of, and my only thought there is that it might be worth a shot to load all groups the user is in into a local variable, then attempt to use those values in your query.  Your mileage may vary.

  • 0
    Certified Senior Developer

    HI Nataasha,

    For problem 2 you can use rule!APN_displayGroupOrUsername(). It will always return you the display name for group or user. (this rule is part of Appian Common Objects)

  • 0
    Certified Lead Developer

    1. The "in" operator works the other way around. You provide a list of values and it checks whether a singular DB value is in that list. I typically use a task report by user and then filter for specific models.

    2. I suggest to not work with type numbers. Use built in type references like type!User or type!User?list. Did a quick test with your code and it works as expected. How did you configure that column in the process report?

  • 0
    Certified Senior Developer
    in reply to Stefan Helzle

    Hello Stefan,

    The code works fine if all the tasks of the process model are assigned to users, throws error if asssigned to a group.I have taken tp!assignee for c6 and im taking the gridcolumn as below: The group() function threw error when loggedinuser was employee as the employee group dint have access to the opertional group and the query was fetching all the tasks of the process model (even operational).

    a!gridColumn(
    label: "Assignee",
    sortField: "c6",
    value: concat(
    a!forEach(
    items: fv!row.c6,
    expression: if(
    runtimetypeof(fv!item) = 4,
    /*User is type 4; group is type 5*/
    user(fv!item, "firstName") & " " & user(fv!item, "lastName"),
    /*Adding char(10) adds line breaks to the list of names*/
    group(fv!item, "groupName")& char(10)
    )
    )
    )
    )

    ill try with tasks by user report .

    Thank you Slight smile

  • 0
    Certified Senior Developer
    in reply to prashantm206

    Hello Prashantm,

    How is that rule configured to check if the given value is user or group? Coz if the pass the name of the user or group in the runtimetypeof() im getting the same number for both. 

    How to distinguish between them is my main concern.

    Thank you Slight smile

  • 0
    Certified Senior Developer
    in reply to Mike Schmitt

    Hello Mike,

    Yes, i agree that the assignment can be in any variation. For my project, only one task is assigned to a group so i may be able to check on the taskname and differentiate between the user assignee and the group but what if other projects need variations? 

    I will try to load all the groups and check as you suggested. I'll update you.

    Thank you Slight smile

  • 0
    Certified Senior Developer
    in reply to natashan0002

    HI Natasha,

    This rule accepts input of type user and group and returns the group or user name. Please check below the code for it

    = if(
    runtimetypeof(ri!groupOrUser) = tointeger(
    'type!{www.appian.com/.../2009}Group'
    ),
    group(togroup(ri!groupOrUser), "groupName"),
    rule!APN_displayUser(touser(ri!groupOrUser))
    )

  • 0
    Certified Senior Developer
    in reply to prashantm206

    Hello Prashantm,

    runtimetypeof(ri!groupOrUser) is giving me 127 whether its a group or user. 

  • 0
    Certified Senior Developer
    in reply to natashan0002

    Hi Natasha,

    Looks like you are getting List of users or group from report. you can use following code to show the comma separated list in grid.

    with(
    local!userOrGoups: fv!item,
    if(
    rule!APN_isBlank(local!userOrGoups),
    "",
    joinarray(
    a!forEach(
    items: local!userOrgroup,
    expression: if(
    runtimetypeof(fv!item) = 4,
    /*User is type 4; group is type 5*/
    user(fv!item, "firstName") & " " & user(fv!item, "lastName"),
    /*Adding char(10) adds line breaks to the list of names*/
    group(fv!item, "groupName") & char(10)
    )
    ),
    ", "
    )
    )
    )

  • 0
    Certified Senior Developer
    in reply to Stefan Helzle

    Hello Stefan,

    I'm getting what i want when i use task report by user, giving the process model in the filter. 

    Thank you Slight smile