Check whether the loggedInUser is in the group or not

Team,

I have a Portal Report of Process Model Context which will have all the tasks. I am using getPortalDataSubset() and converts it into Tempo Report and displaying the same to the end user. I need to place a filter for this report. That is User should see only the tasks pertaining to the user groups he belong to.

Say for example, if the report lists tasks of the groups such as group G1, group G2, group G3 , group G4, group G5.
User A belongs to the groups G2 and G5. When User A login to the report,the user should see the tasks of G2 and G5.
I couldn't use Appian Scripting Functions and related functions such as rule!APN_isLoggedInUserInGroup() , rule!APN_isUserInGroup()
to check whether the loggedInUser is in the group or not.

Please suggest the way to achieve this functionality.

Thanks

OriginalPostID-138726

OriginalPostID-138726

  Discussion posts and replies are publicly visible

  • It may work better to configure the portal report to be of context "my tasks" if that works for this use case. To filter down the "All tasks" report would be more complex.
  • You may want to filter the report dataset in your sail components. Eg include a column in the report about the task assignee or owner, and then in sail filter the dataset based on some criteria. Eg something like this, where I construct a filter for a given district:

    with(
    local!datasubset: getPortalReportDataSubset(reportId: 39035, pagingInfo: local!pagingInfo, contextIds: 2865),
    local!filter: wherecontains(ri!byDistrict, touniformstring(local!datasubset.data[5].cells.value)),

    Now I can apply local!filter to dataset columns like this:

    index(local!datasubset.data[6].cells.value, local!filter)
  • I did achieve the same by using shared component which will return list of groups a user is member of (and pass fn!loggedInUser() as input). Then used the returned group list as filter to the context.
  • @hajii: Thanks..It works..But there is a issue in Pagination. It shows the count of all tasks including those which don't display in the grid.

    @venkats533: Can you please brief more on this?
  • sample code - I am not using pagination, but you can pass a standard a!pagingInfo to get paginated results

    /* use a constant which can be modified to point to different report if required */
    local!portalReportId: cons!BW_CMPO_REPORT_TASKS_FOR_BOTW_GROUP,
    /* known groups that are part of CMPO project */
    local!BOTWGroupList: {
    cons!BW_CMPO_GROUP_SALES,
    cons!BW_CMPO_GROUP_QA,
    cons!BW_CMPO_GROUP_TRAINING
    },
    /* User may belong to more than one group. in that case get all CMPO groups. if the user does not belong to known CMPO groups, do not populate users in filter */
    local!userGroupList: index(
    local!BOTWGroupList,
    apply(
    (
    wherecontains(
    _,
    local!BOTWGroupList
    )
    ),
    local!groupsUserIsMemberOf
    ),
    {}
    ),
    /* data set to be displayed as task report */
    local!fulldatasubset: if(
    isnull(
    local!userGroupList
    ),
              /* user must belong to at least one group, else no report gets displayed */
    null,
              /* Portal to SAIL (forum.appian.com/.../112561) */
    getPortalReportDatasubset(
    reportId: local!portalReportId,
    pagingInfo: a!pagingInfo(
    startIndex: 1,
    batchSize: - 1
    ),
               /* user group list is the context ids */
    contextIds: {
    local!userGroupList
    },
               /* initially on load, no filters are applied */
    filter: {}
    )
    ),
  • forgot the key part - here it is

    /* People Functions - Plug-in forum.appian.com/.../166202 */
    local!groupsUserIsMemberOf: if(
    isnull(
    ri!reportInitiator
    ),
    {},
    getgroupsoftypeforuser(
    ri!reportInitiator,
    "Custom"
    )
    ),