31
Views
7
Comments
Solved by AI
User Management connector Forge component
Question

In the User Management connector for Public APIs, the ApplicationRoles_Query server action under Users → Roles returns a list of application roles based on filters. However, when I bind this list to a dropdown, it displays duplicate roles. How can I ensure only unique roles appear?

2022-04-29 11-28-26
Nitesh Ahirwar
Solution

Hi Amrata,

I think you are fetching roles from ApplicationRoles_Query server action from one or more environments like DEV and QA if you haven't provided stage key that's why its showing roles repeated in the dropdown from both environment in ODC.

In my opinion if your roles are created in any one module then fetch roles from that application only. 

To do that you have to get all application from current environment (DEV or QA) and then pass the application key to ApplicationRoles_Query to get all roles from that module.

Hope this helps .


2023-12-26 10-35-28
OutSystems Neo
Staff
AI Generated

To remove duplicate roles from the ApplicationRoles_Query server action results in the OutSystems User Management Connector's Public APIs, you can process the results systematically. Here's how you can achieve this:

  1. Load the Results: Fetch the results from ApplicationRoles_Query. This will include all roles associated with different users.

  2. Eliminate Duplicates: Use a List Distinct logic to filter out duplicate rows. You can do this using the List manipulation tools available in OutSystems. Typically, you will need to:

    • Loop through the fetched list of roles.
    • Check for duplicates by comparing key attributes (such as RoleName and/or RoleID).
    • Maintain a separate list of unique roles where you add non-duplicate entries.
  3. Implement Aggregates or Server Actions: If you're using aggregates directly in your application, add a filter condition or make use of the "Group By" functionality which can help collapse duplicate rows into unique ones automatically (specific to an attribute, such as RoleName).

    Example of a grouping scenario in an aggregate:

    • Add the RoleName field.
    • Group by RoleName to ensure only unique role names are included in the final list.
  4. Alternative Using SQL (if applicable): If your data is retrieved using Advanced Queries (SQL), you can eliminate duplicates with a SELECT DISTINCT statement. For instance:

    SELECT DISTINCT RoleName
    FROM {UserRole}
    WHERE UserId = @UserId
    

    Replace UserRole with your actual table name and UserId with the filter parameter.

These approaches ensure you're working with unique role data, whether you're using aggregates, server actions, or SQL queries. For a detailed example, the forum discussion on How to list all users with certain roles might offer additional insights into consolidating role data dynamically.

Let me know if you encounter any specific challenges while implementing this!

This answer was AI-generated. Please read it carefully and use the forums for clarifications
2019-11-11 17-10-24
Manish Jawla
 
MVP
2026-01-02 10-25-34
Adi_Dubey

Hii @Amrata Kuchekar 

You can create a local variable and use a For Each loop with ListFilter/ListAny to check for existence before appending to the new list. 

Regards,

Aditya Dubey


2025-09-25 14-38-22
Lokesh Kumar Yadav

In your case, you have used an API. We can also try to make the list distinct, but sometimes this causes issues—for example, when there are extra spaces in the records, duplicate values may still appear. To avoid this, I used an aggregate instead of the API and implemented custom logic to remove duplicate records. This same logic can also be implemented inside a server action. You do not need to change much—only bind the values returned from the API to a structure and apply the duplicate-removal logic there. I have shared the OML; please try this approach, as it should help you   

https://personal-udaksfpd.outsystemscloud.com/RemoveDublicateList/DublicateRecords?_ts=639029699276031527

RemoveDublicateList.oml
2023-10-16 05-50-48
Shingo Lam

Hi,

I think most of our guys proposed the built-in ListDistinct client / server action to resolve the outcome.

In my opinion, you should find out the root cause. I believe you are using the ODC, it centralizes the user once and allows us to grant permission for role on applications and environments. Is it possibly caused by this? Any built-in filters by environment or application? To investigate more, please add more data to show on the dropdown, not just name. Moreover, you can log the returned data from that public API to understand more about the issue

2021-09-06 15-09-53
Dorine Boudry
 
MVP

My guess is that you are not using the filter on stage (environmentKey)

2022-04-29 11-28-26
Nitesh Ahirwar
Solution

Hi Amrata,

I think you are fetching roles from ApplicationRoles_Query server action from one or more environments like DEV and QA if you haven't provided stage key that's why its showing roles repeated in the dropdown from both environment in ODC.

In my opinion if your roles are created in any one module then fetch roles from that application only. 

To do that you have to get all application from current environment (DEV or QA) and then pass the application key to ApplicationRoles_Query to get all roles from that module.

Hope this helps .


Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.