Read only grid in foreach loop

Certified Senior Developer

Hi,

I have a local variable with multiple values. I used foreach loop to iterate a grid. I got multiple grids based on the number of values in the local variable. I have another variable containing users. The user name should be displayed at the top of each grid.

Example if there are 4 grids I need to display 4 names . Each name above each grid. I want to know how to merge these two values to display each user names at the top of each grid.

local!user:ri!selectedLeaderIds (contains Users)

  Discussion posts and replies are publicly visible

  • 0
    Certified Senior Developer

    On top of gridField have you tried using local!userNames[fv!Index] to display name?

  • +1
    Certified Associate Developer

    Hi [Name],

    You're on the right track using a!forEach() to loop over your local!caseGridData. To display a user name above each grid, you can index the corresponding user from your local!user variable using the iteration index (fv!index) within the loop.

    To display the user name, simply use a richTextDisplayField and extract the name using the user() function wrapped around the index() function. Here's a conceptual example:

    This ensures that for each iteration, you're pulling the correct user (e.g., from ri!selectedLeaderIds) that corresponds to the current data in the grid.

    Just ensure:

    • The number of users in local!user matches the number of items in local!caseGridData.

    • You wrap your grid and label in a layout component like cardLayout() or columnsLayout() so the UI is grouped nicely.